gpt4 book ai didi

ios - uiwebview 不适用于 Swift 2.0

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:39:57 24 4
gpt4 key购买 nike

启动模拟器时,我用于 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.
}

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

最佳答案

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

您需要做的是:

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

  2. 在 last 和

    之间放置单词


<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>

  1. 运行你的项目
  2. Source

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com