From 6ecf859a5e2824940fdc38a8974c99c427c06181 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 29 Apr 2019 17:59:01 +0200 Subject: [PATCH] Add custom tap recognizer to text view Stock gesture doesn't work on subview. --- Passepartout-iOS/Scenes/DebugLogViewController.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Passepartout-iOS/Scenes/DebugLogViewController.swift b/Passepartout-iOS/Scenes/DebugLogViewController.swift index 22600797..4b884642 100644 --- a/Passepartout-iOS/Scenes/DebugLogViewController.swift +++ b/Passepartout-iOS/Scenes/DebugLogViewController.swift @@ -52,6 +52,9 @@ class DebugLogViewController: UIViewController { title = L10n.Service.Cells.DebugLog.caption textLog?.contentInsetAdjustmentBehavior = .never + let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(toggleBars)) + textLog?.addGestureRecognizer(tapGestureRecognizer) + NotificationCenter.default.addObserver(self, selector: #selector(vpnDidPrepare), name: .VPNDidPrepare, object: nil) if vpn.isPrepared { startRefreshingLog() @@ -62,18 +65,22 @@ class DebugLogViewController: UIViewController { super.viewWillAppear(animated) navigationController?.isToolbarHidden = false - navigationController?.hidesBarsOnTap = true } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.isToolbarHidden = true - navigationController?.hidesBarsOnTap = false } // MARK: Actions + @objc private func toggleBars() { + let isHidden = navigationController?.isToolbarHidden ?? true + navigationController?.setNavigationBarHidden(!isHidden, animated: true) + navigationController?.setToolbarHidden(!isHidden, animated: true) + } + @IBAction private func share(_ sender: Any?) { guard let raw = textLog?.text, !raw.isEmpty else { let alert = Macros.alert(title, L10n.DebugLog.Alerts.EmptyLog.message)