简体   繁体   中英

Using WKWebView in my current project results in a blank screen

I have seen many many q/a on this topic including here , here and here . I believe I have tried every answer given. This is annoying, as I'm using my technique in four other apps and they are working fine. I even copied the code and storyboard from one project that does work to this one, but still no joy.

My code is this:

import Cocoa
import WebKit


    class HelpViewController: NSViewController {

         @IBOutlet var webView: WKWebView!


        override func viewDidLoad() {
              super.viewDidLoad()

            let url = URL(string:"https://www.apple.com")!
            webView.load(URLRequest (url: url))

          }

    }

I have my info.plist without NSAppTransportSecurity

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

although I've tried it as well with this code included.

Under ProjectName > Signing and Capabilities, I have this:

在此处输入图像描述

I must be missing something, but I'm asking here in case someone else has also experienced this. I'm using Xcode 11.4 (and I've tried 11.5 b1).

Thanks in advance for any places I can look.

In case anyone else has this problem, I resolved it by turning off the AppSandbox in the info.plist file.

Run the app again, the link worked.

Turn the AppSandbox on again. Turn on the outgoing connections.

The problem was solved for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM