How to load URL in UIWebView in Swift?

前端 未结 18 1497
南旧
南旧 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 01:07

    Loading URL to WebView is very easy. Just create a WebView in your storyboard and then you can use the following code to load url.

        let url = NSURL (string: "https://www.simplifiedios.net");
        let request = NSURLRequest(URL: url!);
        webView.loadRequest(request);
    

    As simple as that only 3 lines of codes :)

    Ref: UIWebView Example

提交回复
热议问题