UIWebView的一个简单实现
2016-05-17 14:50
465 查看
@property(weak,nonatomic) UIWebView *webView;
//确定一个要访问的资源 NSURL *url = [NSURL URLWithString:@"http://m.baidu.com"]; //建立请求,准备告诉服务器端,我们客户端需要的资源 NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:url]; //表明自己的设备属性以返回对应数据 [request setValue:@"Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_1 like MacOS X) AppleWebKit/600.1.4 (KHTML, like Gecko)" forHTTPHeaderField:@"User-Agent"]; //把请求发送给服务器,等处理完后,返回数据 [NSURLConnection sendAsynchoronousRequest:request queue: [[NSOperationQueue alloc] init] completionHandler: ^(NSURLResponse *response, NSData *data, NSError *connectionError) { NSString *heml = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; [self.webView loadHTMLString:html baseURL:nil]; }
相关文章推荐
- IOS中UIWebView的使用详解
- IOS之UIWebView的使用(基本知识)
- 实例详解IOS开发之UIWebView
- IOS中使用UIWebView 加载网页、文件、 html的方法
- 在iOS应用中使用UIWebView创建简单的网页浏览器界面
- IOS中UIWebView加载Loading的实现方法
- UIWebView
- UIWebView总结
- IOS属性--UIWebView
- IOS之UIWebView的使用
- UIWebview点击图片实现大图浏览
- ios的webView加载本地html图片路径显示及webview适配
- 关于 UIWebView 加载后为空白页
- 使用UIWebView与html实现网络请求
- 轻描淡写iOS--UIWebview中网页宽度自适应
- UIWebView中Html中用JS调用OC方法及OC执行JS代码
- UIWebView内容搜索并且显示高亮背景颜色
- tableViewCell 上面webView 自适应高度
- UIScrollView的使用大全--contentsize,contentInset和contentInset
- iOS开发怎么加入优酷视频播放功能