使用UIWebView加载来自NetWork、Project、Documents的html、javascript文件
来源:互联网 发布:直播软件露鸟 编辑:程序博客网 时间:2024/06/05 17:16
话不多少,直接上代码,思路还是挺简单的。
UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.frame]; // HTML文件来自Project // 步骤:path - > url - > request with url - > loadRequest NSString *path_Proj = [[NSBundle mainBundle]pathForResource:@"index" ofType:@"html"]; NSURL *url_Proj = [NSURL fileURLWithPath:path_Proj]; NSURLRequest *request_local = [NSURLRequest requestWithURL:url_Proj]; [webView loadRequest:request_local]; // HTML文件来自Documents // 步骤:pathArrary - > path - > url - > request with url - > loadRequest NSArray *pathArrary = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [pathArrary objectAtIndex:0]; NSString *path_Doc = [documentsDirectory stringByAppendingPathComponent:@"index.html"]; NSURL *url_Doc = [NSURL fileURLWithPath:path_Doc]; NSURLRequest *request_Doc = [NSURLRequest requestWithURL:url_Doc]; [webView loadRequest:request_Doc]; // HTML文件来自Network // 步骤:url - > request with url - > loadRequest NSURL *url_net = [NSURL URLWithString:@"http://文件地址/index.html"]; NSURLRequest *request_net = [NSURLRequest requestWithURL:url_net]; [webView loadRequest:request_net];
0 0
- 使用UIWebView加载来自NetWork、Project、Documents的html、javascript文件
- 总结-UIWebView的使用-加载网页、html文件、本地文件等
- iOS UIWebView 加载本地html文件 同时加载javascript文件,javascript文件无效
- UIWebView加载的html里,加载工程文件的图片
- UIWebView加载本地HTML文件
- UIwebview加载本地html文件
- UIWebView加载本地HTML文件
- UIWebview加载本地html文件
- ios UIWebView 加载本地html,js,css文件的问题
- UIWebView加载网页、文件及html的方法
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- iOS UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- 成功企业是“架构”出来的
- 微软STC实习生面试
- Proxy(代理)
- 黑马程序员_线程高级_多线程,同步,互斥,线程数据共享
- CCClippingNode(Clip修剪 可以实现新手引导遮罩、滚动字幕。。渲染child时仅渲染模板透明度值大于透明度阀值的像素点.默认透明度阀值 =1)
- 使用UIWebView加载来自NetWork、Project、Documents的html、javascript文件
- 大图用 imageWithContentsOfFile 小图用imageNamed
- CCParticleSystemQuad
- Java反射分析对象的Fields
- 程序员网址大全
- WARN No appenders could be found for logger...
- 错误“Unexpected namespace prefix "xmlns" found for tag LinearLayout”的解决方法
- Jtester+unitils+testng:DAO单元测试文件模板自动生成
- CCParticleSystem