Update address bar when active webView url changes

This commit is contained in:
CypherPoet 2019-02-20 19:13:03 -05:00
parent 1dcd5af85e
commit 85d0948e7c
1 changed files with 8 additions and 1 deletions

View File

@ -21,6 +21,7 @@ class HomeViewController: UIViewController {
weak var activeWebView: WKWebView! {
didSet {
activeWebViewChanged()
updateAddressBar(for: activeWebView)
}
}
@ -53,6 +54,10 @@ class HomeViewController: UIViewController {
title = defaultTitle
}
func updateAddressBar(for webView: WKWebView) {
addressBar.text = webView.url?.absoluteString ?? ""
}
func replaceActiveWebView(afterDeletingFromIndex previousIndex: Int) {
if stackView.arrangedSubviews.isEmpty {
activeWebView = nil
@ -111,7 +116,9 @@ class HomeViewController: UIViewController {
extension HomeViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
updateAddressBar(for: webView)
}
}