Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kiritmodi2702/926c4869206fd11cfa09f5219c96937b to your computer and use it in GitHub Desktop.
Save kiritmodi2702/926c4869206fd11cfa09f5219c96937b to your computer and use it in GitHub Desktop.
WKwebView
import UIKit
import WebKit
class ViewController: UIViewController , WKNavigationDelegate{
var webView : WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// loading URL :
let myBlog = "https://iosdevcenters.blogspot.com/"
let url = NSURL(string: myBlog)
let request = NSURLRequest(URL: url!)
// init and load request in webview.
webView = WKWebView(frame: self.view.frame)
webView.navigationDelegate = self
webView.loadRequest(request)
self.view.addSubview(webView)
self.view.sendSubviewToBack(webView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK:- WKNavigationDelegate
func webView(webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError) {
print(error.localizedDescription)
}
func webView(webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
print("Strat to load")
}
func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
print("finish to load")
}
}
@kiritmodi2702
Copy link
Author

kiritmodi2702 commented May 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment