首页 > 解决方案 > 在 webView 中加载网站时出现 Swift 错误

问题描述

这是error我得到的:

获取断言时出错:<Error Domain=RBSAssertionErrorDomain Code=3“目标未运行或缺少所需的目标权利”UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target 未运行或缺少所需的目标权利}>

我的segmentedController里面webView有三个选项:

    //MARK: segControlAction
@objc func segControlAction(sender: UISegmentedControl) {
    switch sender.selectedSegmentIndex {
    case 0: // google
        let myURL = URL(string: "https://www.google.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
        
    case 1: // amazon
        let myURL = URL(string: "https://www.amazon.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
        
    case 2: // adidas
        let myURL = URL(string: "https://www.adidas.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    
    default:
        let myURL = URL(string: "https://www.google.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }
}

谷歌亚马逊工作得很好,但case 2(“https://www.adidas.com”)没有加载……我在这里错过了什么?

标签: ioswebviewuiwebviewwkwebview

解决方案


推荐阅读