Created
May 27, 2016 07:01
-
-
Save kiritmodi2702/926c4869206fd11cfa09f5219c96937b to your computer and use it in GitHub Desktop.
WKwebView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See steps of WKWebView : https://iosdevcenters.blogspot.com/2016/05/creating-simple-browser-with-wkwebview.html