How to load URL on WKWebView?
First of all you need to import
import WebKit
Following code is enough to open URL with WKWebView
let webView = WKWebView(frame: <#AnyRect#>)
let link = URL(string:"https://developer.apple.com/videos/play/wwdc2019/239/")!
let request = URLRequest(url: link)
webView.load(request)
Use -
webView.load(URLRequest(url: URL(string: "https://www.google.com/")!))
For Objective-c
- Goto Target -> Frameworks, Libraries, and Embed content
- Add Framework "WebKit.framework"
- Open your file and add #import
implement code in the function that you want to load WKWebView
WKWebView *webView = [[WKWebView alloc] init];
webView.frame = self.view.bounds;
[self.view addSubview:webView];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.apple.com"]];
[webView loadRequest:request];