Created
December 31, 2017 12:35
-
-
Save josefrichter/4938422248eac1babbd5bcec989cca7c to your computer and use it in GitHub Desktop.
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 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