WKWebView not loading webpage - renders blank screen in Swift

后端 未结 5 1864
渐次进展
渐次进展 2020-12-11 00:48

This code is supposed to load the Apple homepage, but instead shows a blank screen.
This happens with both HTTP and HTTPS URLs.

Code:

import UIK         


        
5条回答
  •  眼角桃花
    2020-12-11 01:51

    The following code works just fine for me in Xcode 9.3:

    import UIKit
    import WebKit
    
    class ViewController: UIViewController {
    
        var webView: WKWebView!
    
        override func loadView() {
            webView = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
            self.view = webView
        }
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            webView.load(URLRequest(url: URL(string: "https://www.apple.com")!))
        }
    
    }
    

    Here's the result:

提交回复
热议问题