From 44476b1caef3e4ab5cc3487df1e17dd24cd918fc Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Tue, 8 Mar 2022 11:51:31 +0900 Subject: [PATCH] =?UTF-8?q?#28=20=E3=82=BF=E3=83=96=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E6=99=82=E5=88=9D=E6=9C=9FURL=E8=A1=A8=E7=A4=BA=E3=83=BB?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=AE=E9=80=A3=E6=89=93=E9=98=B2=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebView/View/WebViewController.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/AgileWorks/AgileWorks/WebView/View/WebViewController.swift b/AgileWorks/AgileWorks/WebView/View/WebViewController.swift index 68a4828..72a736e 100644 --- a/AgileWorks/AgileWorks/WebView/View/WebViewController.swift +++ b/AgileWorks/AgileWorks/WebView/View/WebViewController.swift @@ -30,6 +30,9 @@ class WebViewController: UIViewController { private let queue = DispatchQueue(label: "jp.atled.agileworks") var isShowDoc = false + // 現在表示中のURL + var nowURL: String! + // Title を設定する URL を定義 let urlToTitle: [String: String] = [ "Mobile#home": localizadString(key: "HomeTitle", comment: ""), @@ -53,6 +56,7 @@ class WebViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.navigationItem.title = naviTitle + self.tabBarController?.delegate = self } // WebView セットアップ @@ -99,7 +103,7 @@ class WebViewController: UIViewController { // WebView ロード処理 private func loadWebView() { - let sesstionid = "JSESSIONID=" + sessionId! + let sesstionid = "JSESSIONID=" + self.sessionId! let url = URL(string: self.loadURL)! var request = URLRequest(url: url, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 30.0) @@ -233,6 +237,7 @@ class WebViewController: UIViewController { case "URL"?: if let url = change![NSKeyValueChangeKey.newKey] as? URL { let urlString: String = url.absoluteString + self.nowURL = urlString for (key, value) in self.urlToTitle { if urlString.contains(key) { // タイトルの再設定 @@ -364,3 +369,12 @@ extension WebViewController: UIScrollViewDelegate { scrollView.pinchGestureRecognizer?.isEnabled = false } } + +extension WebViewController: UITabBarControllerDelegate { + func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) { + if loadURL != nowURL { + loadWebView() + } + } +} + -- GitLab