Skip to content

Instantly share code, notes, and snippets.

@tempire
Last active February 16, 2019 17:06
Show Gist options
  • Save tempire/717eb132e34471ae28f7aed94d65a17a to your computer and use it in GitHub Desktop.
Save tempire/717eb132e34471ae28f7aed94d65a17a to your computer and use it in GitHub Desktop.
// In the MTR view controller
let vc = storyboard.instantiateViewController(withIdentifier: "WebViewController")
self.navigationController?.pushViewController(vc, animated: true)
// Web View Controller, assuming a matching view controller in the storyboard
class WebViewController: UIViewController {
@IBOutlet weak var webView = WKWebView()
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://whatever")
let request = URLRequest(url: url)
webView.navigationDelegate = self
webView.load(request)
// If loading a PDF from disk
// webView.loadFileURL(url, allowingReadAccessTo: url)
}
}
extension WebViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
completionHandler(.performDefaultHandling, nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment