I have the following code:
UIWebView.loadRequest(NSURLRequest(URL: NSURL(string: "google.ca")))
I am getting the following error:
'NSURLRequest' is not convertible to UIWebView.
Any idea what the problem is?
I have the following code:
UIWebView.loadRequest(NSURLRequest(URL: NSURL(string: "google.ca")))
I am getting the following error:
'NSURLRequest' is not convertible to UIWebView.
Any idea what the problem is?
Try this:
Add UIWebView to View.
Connect UIWebview outlet using assistant editor and name your "webview".
UIWebView Load URL.
And run the app!!
You can load a page like this :
Or the one-line approach :
webView is your outlet var.
Swift 3 doesn't use NS prefix anymore on URL and URLRequest, so the updated code would be:
Easy,Tested and working 100%
Import webkit :
Assign IBOutlet to webview:
set delegate:
Write code on viewDidLoad():
Write delegate methods:
look like:
In Swift 4 or 4.2 You can use like:
Your view is like bellow:
Allow Allow Arbitrary Loads true info.plist
Note info.plist will look like bellow