更新时间:2022-10-19 12:03:09
HTML文件:
< HTML>
< HEAD>
< TITLE>我的网页< / TITLE>
< / HEAD>
< BODY>
< img alt =src =1.jpgstyle =width:100px; height:100px;/>
< P>您可以在此输入想要在浏览器窗口中显示的所有文字和图片。< / P>
< / BODY>
< / HTML>
webView代码:
NSString * htmlFile = [[NSBundle mainBundle] pathForResource:@deskofType:@html];
NSURL * url = [NSURL fileURLWithPath:htmlFile];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
截图:
I want to load an HTML file in an UIWebView using following lines of code:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"01Numbers" ofType:@"html"];
NSURL *url=[NSURL fileURLWithPath:htmlFile];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
[WebView loadRequest:request];
I am able to load the HTML file, but this HTML file also contain some images, and that images are not loading/visible in the view, can anyone suggest any solution for this?
HTML File:
<HTML>
<HEAD>
<TITLE>My Web Page</TITLE>
</HEAD>
<BODY>
<img alt="" src="1.jpg" style="width: 100px; height: 100px;"/>
<P>This is where you will enter all the text and images you want displayed in a browser window.</P>
</BODY>
</HTML>
webView code:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"desk" ofType:@"html"];
NSURL *url=[NSURL fileURLWithPath:htmlFile];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
screenshot: