diff --git a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj index 10691b20fcf45ac6af5be1619e51502229b83c45..2c0de42b3d96a987ae1e6f44bf0015c67ae16bfc 100644 --- a/AgileWorks/AgileWorks.xcodeproj/project.pbxproj +++ b/AgileWorks/AgileWorks.xcodeproj/project.pbxproj @@ -1822,7 +1822,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1996,7 +1996,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/AgileWorks/AgileWorks/WebView/View/WebViewController.swift b/AgileWorks/AgileWorks/WebView/View/WebViewController.swift index 4cdd571ec243eea05a935aef7b9dd9e620a045e5..4a17a825a818fecf4c7fa03cae9aaff226c4b794 100644 --- a/AgileWorks/AgileWorks/WebView/View/WebViewController.swift +++ b/AgileWorks/AgileWorks/WebView/View/WebViewController.swift @@ -18,9 +18,10 @@ class WebViewController: UIViewController { @IBOutlet private var closeButton: UIBarButtonItem! @IBOutlet private var menuButton: UIBarButtonItem! var mainWebView: WKWebView! - var subWebView: WKWebView! // 別ウインドウで開いたときの子ウインドウスタック var subViewStack = SubViewStack() + //subWebView読み込みフラグ + var subWebViewLoadingFlg = false var loadURL: String! var reloadTab = false var showNotification = false @@ -464,17 +465,18 @@ extension WebViewController: WKUIDelegate { func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { if navigationAction.targetFrame?.isMainFrame != true { - subWebView = WKWebView(frame: self.formView.bounds, configuration: configuration) - subWebView.navigationDelegate = self - subWebView.uiDelegate = self - subViewStack.push(subWebView, superView: mainWebView) - subWebView.load(navigationAction.request) - - //キャンセルボタンの表示 - self.closeButton.title = getDisplayString(key: "Close", comment: "") - self.closeButton.isEnabled = true - - return subWebView + if !subWebViewLoadingFlg { + subWebViewLoadingFlg = true + let subWebView = WKWebView(frame: self.formView.bounds, configuration: configuration) + //読み込むが非表示 + subWebView.isHidden = true + subWebView.navigationDelegate = self + subWebView.uiDelegate = self + subViewStack.push(subWebView, superView: mainWebView) + subWebView.load(navigationAction.request) + + return subWebView + } } return nil } @@ -497,6 +499,15 @@ extension WebViewController: WKNavigationDelegate { download(url: url, saveAs: attachmentFileName) decisionHandler(.cancel) } else { + //subWebViewの場合 + if !subViewStack.isEmpty { + //subWebViewの表示 + webView.isHidden = false + //キャンセルボタンの表示 + self.closeButton.title = getDisplayString(key: "Close", comment: "") + self.closeButton.isEnabled = true + subWebViewLoadingFlg = false + } decisionHandler(.allow) } } @@ -614,9 +625,20 @@ extension WebViewController: WKNavigationDelegate { } DispatchQueue.main.async {[self] in let activityViewController = UIActivityViewController(activityItems: [tempPath], applicationActivities: nil) + //iPadのみ + if UIDevice.current.userInterfaceIdiom == .pad { + let deviceSize = UIScreen.main.bounds + if let popPC = activityViewController.popoverPresentationController { + popPC.sourceRect = CGRect(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height / 2, width: 0, height: 0) + popPC.sourceView = self.view + popPC.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0) + } + } activityViewController.completionWithItemsHandler = { (activityType: UIActivity.ActivityType?, completed: Bool, returnedItems: [Any]?, activityError: Error?) in + //subWebViewを消す self.closeTapped() - + subWebViewLoadingFlg = false + guard completed else { return }