iOS有一个控件可以展示url请求访问浏览器得到的资源并显示出来。该控件是UIWebView。
NSURL * url = [NSURL URLWithString:@"http://m.baidu.com"];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
只需要上面的三行代码就可以显示访问到的页面的内容。
但是,如果使用XCode7运行上面的 代码是报错。
Application Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app‘s Info.plist file.
我们只需要修改一下info.plist文件就可以正确运行程序了。