书籍是1.X多,里面有说到 UIWebView
@IBAction func buttonClick(sender: UIButton) {
var str=textURL.text
if str!.hasPrefix("http://"){
str="http://" + str!
}
var url=NSURL(string: str!)
var request=NSURLRequest(URL: url!)
webView!.loadRequest(request)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
var url=NSURL(string:"https://www.google.com.tw")
print(url)
var request=NSURLRequest(URL:url!)
webView!.loadRequest(request)
// Dispose of any resources that can be recreated.
}
上网查了一下,好像是安全性的问题,说在 info.plist 加上
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
但我加了也没用,请问这是怎么回事 求大大解
终于解决了 ,感谢大大