我创建了一个UIWebView
并使用HTML文件显示一些内容。但是当我运行它而不是显示内容时,只有整个HTML文件编码才会进入WebView。请帮助并告诉我什么是错的。使用UIWebView显示html文件
UIWebView *ingradients= [[UIWebView alloc]init];
[ingradients setFrame:CGRectMake(10, 170, 300, 300)];
[ingradients loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"htmlfile" ofType:@"html"]isDirectory:NO]]];
ingradients.delegate=self;
[self.view addSubview:ingradients];
我htmlfile.html包含
<html>
<body>
<p><strong>Ingredients</strong></p>
</body>
</html>
而不是显示在大胆 “配料”,它显示htmlfile.html
刚才我注意到,当我在浏览器中打开HTML文件还显示其在整个编码。你能告诉我会有什么问题吗? – Newbee 2013-02-28 08:47:59
更改URl和检查 – iPatel 2013-02-28 08:50:04
我实际上已经尝试** loadHTMLstring **方法,并将HTML编码作为字符串参数,并且其工作正常.... :) – Newbee 2013-02-28 09:09:54