Reputation: 569
im trying to use the UI WebKit View.
I created a single view app, placed a UI WebKit View on the main View and put the constraints "centering horizontally and vertically in container, fixed height and equal width to superview" to it.
then i changed my ViewController.swift to
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let myUrl = URL(string: "www.apple.com")
let myRequest = URLRequest(url: myUrl!)
webView.load(myRequest)
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
But when i start the app i get only a blank screen. What am i doing wrong?
Upvotes: 1
Views: 416
Reputation: 100541
Your url is not valid so change this
let myUrl = URL(string: "www.apple.com")
to
let myUrl = URL(string: "https://www.apple.com")
Upvotes: 2