How to load URL in UIWebView in Swift?

前端 未结 18 1462
南旧
南旧 2020-11-29 00:58

I have the following code:

UIWebView.loadRequest(NSURLRequest(URL: NSURL(string: \"google.ca\")))

I am getting the following error:

18条回答
  •  眼角桃花
    2020-11-29 00:59

    You can load a page like this :

    let url: URL = URL(string:"https://google.com")!
    webView.loadRequest(URLRequest.init(url: url))
    

    Or the one-line approach :

    webView.loadRequest(URLRequest.init(url: URL(string: "https://google.com")!))
    

    webView is your outlet var.

提交回复
热议问题