Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import UIKit
import WebKit
class MagazineViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var webview: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// TODO replace URL here
let url = URL(string: "https://www.mrgoodlife.net/en/")
webview.loadRequest(URLRequest(url: url!))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func webViewDidStartLoad(_ webView: UIWebView) {
if webview.canGoBack {
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "BACK", style: UIBarButtonItemStyle.plain, target: self, action: #selector(goBack))
} else {
self.navigationItem.leftBarButtonItem = nil
}
}
@objc func goBack() {
webview.goBack()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.