OGeek|极客世界-中国程序员成长平台

标题: ios - uiwebview 不适用于 Swift 2.0 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:43
标题: ios - uiwebview 不适用于 Swift 2.0

我在 Xcode 6.4 中用于打开 uiwebview 的代码在启动模拟器时不会为 Xcode 7 加载。

class ViewController: UIViewController {

@IBOutlet var webLaundry: UIWebView!


func loadWebPage(){
    let theURL = "http://www.google.com"
    let theRequestURL = NSURL (string: theURL)
    let theRequest = NSURLRequest (URL: theRequestURL!)
    webLaundry.loadRequest(theRequest)
}

override func viewDidLoad() {
    super.viewDidLoad()
    loadWebPage()
    // Do any additional setup after loading the view, typically from a nib.
}

我应该改变什么来解决这个问题?



Best Answer-推荐答案


这是苹果新的安全要求。 iOS 9 中的应用程序传输安全性。

你需要做的是:

  1. 在xcode 7中,在你的项目中,找到“Info.plist”,右键,以“源代码”打开。

  2. 把单词放在最后和

  3. 之间

NSAppTransportSecurity <字典> NSAllowsArbitraryLoads

  1. 运行你的项目
  2. Source

关于ios - uiwebview 不适用于 Swift 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32723488/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4