Reputation: 103
I have been attempting to load a webpage in iOS to no avail. I have used the same code on other view controllers in the project but all it shows for this page is the blank white screen. Here is my code:
import UIKit
import WebKit
class FirstViewController: UIViewController {
@IBOutlet weak var webView: WKWebView!
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear( animated )
let url:URL = URL(string: "http://www.fairburyjeffs.org")!
let urlRequest:URLRequest = URLRequest(url: url)
webView.load(urlRequest)
}
Upvotes: 0
Views: 3544
Reputation: 958
You are trying to load an HTTP url (i.e "http://www.fairburyjeffs.org") so make sure that you have set Arbitary Loads to YES in info.plist. If you don't set Arbitary Loads to YES, the http pages won't load.
Upvotes: 1
Reputation: 2425
Your code are working fine as you wanted to-
The reason i found behind this -
If you try https://www.google.com/ . It will work in one RUN.
But when you run it with your url
it won't. Why? because the
difference of http
and https
. For more you can read the Apple
documentations.
You just need to do the following steps-
And after that just add those two lines in your Info.plist
(as it is) -
Upvotes: 3