首页 > Web开发 > 详细

UIWebView的三种加载方式

时间:2014-12-11 00:17:02      阅读:387      评论:0      收藏:0      [点我收藏+]
1、直接给出url地址即可将web content载入。
NSString *path = @"http://theo2life.com";  
NSURL *url = [[NSURL alloc] initWithString:path];  
[self.webView loadRequest:[NSURLRequest requestWithURL:url]]; 

2、将本地html文件内容嵌入webView
NSString *resourcePath = [ [NSBundle mainBundle] resourcePath];  
NSString *filePath  = [resourcePath stringByAppendingPathComponent:@"test.html"];  
NSString *htmlstring =[[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];   
[self.webView loadHTMLString:htmlstring  baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle]  bundlePath]]];  


3.如果不从html文件载,直接加载NSString:
NSString *HTMLData = @"<img src=\"test.png\" />hello web";  
[self.webView loadHTMLString:HTMLData baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle]  bundlePath]]];  


UIWebView的三种加载方式

原文:http://blog.csdn.net/cerastes/article/details/41856509

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!