import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
var webView : WKWebView!
override func loadView() {
webView = WKWebView()
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://www.google.com")!
webView.load(url)
webView.allowsBackForwardNavigationGestures = true
}
}
Hello, I am new to Swift programming. I am trying to load a simple website on navigation controller with the help of WKWebView. But I am unable to continue with it. As I am facing an error with line
let URL = let url = URL(string: "https://www.google.com")!
I need to know two things
The error is pretty clear. You need to pass a URLRequest
object as parameter.
let url = URL(string: "https://www.google.com")!
webView.load(URLRequest(url: url))