2010-07-28 74 views
1

我是iPhone編程的新手.. 我有一個html文件..在那3行文本。 我想在消息部分的alertview中顯示該文本。 爲此,我們需要讀取html並將數據存儲在一個字符串中.Den使用那個sting作爲消息... 我是對的..? 然後hw讀取html以及如何將其存儲在字符串中..?如何在UIAlertView中顯示HTML文件的文本作爲消息

請幫我

感謝ü ......

的NSString *路徑= [[一個NSBundle mainBundle] pathForResource:chapter.page ofType:@ 「HTML」]; NSString * content = [NSString stringWithContentsOfFile:path encoding:NSASCIIStringEncoding error:NULL];

UIAlertView *tAlert = [[UIAlertView alloc] initWithTitle:nil message:content delegate:self 
              cancelButtonTitle:nil otherButtonTitles:@"CLICK HERE", @"OR CONTINUE", @"OR BACK",nil]; 


    tAlert.tag=TOSChapter; 

    [tAlert show]; 

    [tAlert release]; 

在這個它顯示html的所有標籤...而不是解析html是否有任何其他方式來顯示在alertview中的HTML內容..?

感謝ü...

回答

0

要從資源加載文件:

NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"yourfile" ofType:@"html"];  
NSString *content = [NSString stringWithContentsOfFile: htmlPath encoding:NSASCIIStringEncoding error:NULL]; 

然後,解析您的子HTML。

+0

感謝樓Lou Franco..for快速反應... Shold我解析得到的數據在html ...? 我不能將這個HTML文件(webView)作爲子視圖添加到UIAlertView ..? 還是有其他方法..? 再次感謝.. – rockey 2010-07-29 22:31:22

+0

我不確定這會工作 - 我想你可以試試。 – 2010-07-30 02:13:40