2014-02-27 15 views
0

我试图表明一个html页是我的应用程序里面,但它并没有在视图上显示:由iOS - display content from an html resource file or remote webpage in a webview显示HTML页面在我的iPhone观点

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"abt.html"]; 
NSURLRequest *documentsRequest = [NSURLRequest requestWithURL: 
            [NSURL fileURLWithPath:path]] ; 

[_webview loadRequest:documentsRequest] ; 

我跟着这个链接马特吉布森

请让我知道如何显示。

感谢

+0

这里可能有很多错误...... webView可能无法正确初始化,“Path”变量可能是空的。您需要提供更多信息。 –

回答

0

正如你说你的HTML页面里面的应用程序,所以尝试这一个,我用它和它的做工精细。

NSString *htmlFile=[[NSBundle mainBundle] pathForResource:@"abt" ofType:@"html"]; 
NSString *htmlString=[NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:Nil]; 
[_webview loadHTMLString:htmlString baseURL:nil]; 
+0

它适合你吗? –