转载:UIWebView用法
2011-11-24 21:22
369 查看
转载自 http://www.devdiv.com/home.php?mod=space&uid=11826&do=blog&id=6081
已有 201 次阅读 2011-10-28 17:31 |个人分类:ios| UIWebView
1.NSString *webpage = [NSBundle pathForResource:@"webpage" ofType:@"html" inDirectory:[[NSBundle mainBundle]bundlePath]];
1.[uiwebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://zgia.net/"]]];
添加UIWebViewDelegate代理
转载:UIWebView用法
已有 201 次阅读 2011-10-28 17:31 |个人分类:ios| UIWebView
载入HTML 1
NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; NSString *filePath = [resourcePath stringByAppendingPathComponent:@"webpage.html"]; NSString *htmlstring=[[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; [uiwebview loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
载入HTML 2
1.NSString *webpage = [NSBundle pathForResource:@"webpage" ofType:@"html" inDirectory:[[NSBundle mainBundle]bundlePath]];2.[uiwebview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:webpage]]];
载入HTML 3
1.[uiwebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://zgia.net/"]]];
点击链接使用Safari打开
添加UIWebViewDelegate代理uiwebview.delegate = self; #pragma mark - #pragma mark UIWebViewDelegate - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if(navigationType == UIWebViewNavigationTypeLinkClicked) { [[UIApplication sharedApplication] openURL:request.URL]; return NO; } else { return YES; } }
相关文章推荐
- VC常用控件用法(转载)
- [转载]gate 的用法
- 【转载】Java中this与super的几种用法与区别
- (转载)#pragma pack 用法详解
- .NET(c#)new关键字的三种用法 (转载)
- 常见的四种排名函数的用法----转载
- EXTJS学习系列基础篇:第八篇(转载)作者殷良胜,Ext组件系列之--textfield组件的基本用法
- 【转载】 extern "C"的用法解析
- 转载 sizeof怎样用法
- [转载]Java程序设计中setFont()函数的用法
- for_each的用法,转载自蕭鴻森的blog
- [转载]关于generate用法的总结【Verilog】
- JS中数组Array的用法{转载}
- UIWebView的一些用法总结
- (转载)expdp / impdp 用法详解
- SQL中HAVING从句的用法和联结(JOIN)语法(转载)
- 【转载】ROW_NUMBER() OVER函数的基本用法用法
- iOS-69-WKWebview用法与UIWebview对比(附demo、PPT)
- Android Volley完全解析(一),初识Volley的基本用法 转载地址:http://blog.csdn.net/guolin_blog/article/details/17482095
- 【收藏贴】--切勿转载 Android之Adapter用法总结