关于WKWebView显示网页的问题

sai8808
  • 779

移动开发新手,直接从Swift入门了,想先调用WKWebView显示一个网页,语句没有报错,但是显示出来的内容是空的。网上搜的教程和案例大都是OC的写法,求教

import UIKit
import WebKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let theConfiguration = WKWebViewConfiguration()
        let webview = WKWebView(frame: self.view.frame, configuration: theConfiguration)
        self.view.addSubview(webview)
        webview.loadRequest(NSURLRequest(URL: NSURL(string: "http://baidu.com")!))
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
回复
阅读 2.7k
1 个回答
宣传栏