Created
May 27, 2016 06:56
-
-
Save kiritmodi2702/b8a674bb66803c1397cab55030ae2c54 to your computer and use it in GitHub Desktop.
WKWebView in Swift.
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") | |
} | |
} |
Any recent updates on this for xcode 8?
i got below error while
let myUrl = "https://www.google.com/"
let url = NSURL(String:myUrl) . //Argument labels '(String:)' do not match any available overloads
let request = NSURLRequest(URL: url)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the steps on the tutorial : https://iosdevcenters.blogspot.com/2016/05/creating-simple-browser-with-wkwebview.html