【问题标题】:WKWebView is only displays apple siteWKWebView 仅显示苹果网站
【发布时间】:2019-01-08 10:38:37
【问题描述】:

我一直在检查苹果文档:https://developer.apple.com/documentation/webkit/wkwebview 和堆栈的答案,我在使用苹果官方苹果文档时收到了任何答案,我只能访问苹果的网站,除此之外别无其他。

这是我的代码(在苹果上发布)

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        let myURL = URL(string:"https://www.google.com")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }
}

我已添加 p.list 选项:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>https://www.google.com</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>
        </dict>
    </dict>

除苹果网站外,没有其他方法有效 而且我还没有在网上找到相关的答案 正如我提到的,我已经在 apple doc' 和 here 中进行了搜索。 感谢您的所有想法!

【问题讨论】:

  • 你用过ios模拟器吗?我也有同样的症状。但是当我在我的 iPhone 上安装该应用程序时,它就可以工作了。我认为这是一个模拟器错误。 My SimulatorMy Phone
  • 你是对的。我一直在用模拟器

标签: ios xcode webkit plist wkwebview


【解决方案1】:

模拟器错误 在真实设备中工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-21
    • 2016-03-29
    • 2018-09-15
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多