Browse Source

remove gestureRecognizer from navBar tap before chatDetail is pushed

Bastian van de Wetering 6 năm trước cách đây
mục cha
commit
e500a4fbc6

+ 11 - 2
deltachat-ios/Controller/ChatViewController.swift

@@ -26,6 +26,10 @@ class ChatViewController: MessagesViewController {
   var msgChangedObserver: Any?
   var msgChangedObserver: Any?
   var incomingMsgObserver: Any?
   var incomingMsgObserver: Any?
 
 
+	lazy var navBarTap: UITapGestureRecognizer = {
+		return UITapGestureRecognizer(target: self, action: #selector(chatProfilePressed))
+	}()
+
   var disableWriting = false
   var disableWriting = false
 
 
   var previewView: UIView?
   var previewView: UIView?
@@ -47,8 +51,6 @@ class ChatViewController: MessagesViewController {
     messagesCollectionView.register(CustomCell.self)
     messagesCollectionView.register(CustomCell.self)
     super.viewDidLoad()
     super.viewDidLoad()
     view.backgroundColor = DCColors.chatBackgroundColor
     view.backgroundColor = DCColors.chatBackgroundColor
-    let navBarTap = UITapGestureRecognizer(target: self, action: #selector(chatProfilePressed))
-    navigationController?.navigationBar.addGestureRecognizer(navBarTap)
     if !MRConfig.configured {
     if !MRConfig.configured {
       // TODO: display message about nothing being configured
       // TODO: display message about nothing being configured
       return
       return
@@ -77,6 +79,10 @@ class ChatViewController: MessagesViewController {
 
 
   override func viewWillAppear(_ animated: Bool) {
   override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(animated)
     super.viewWillAppear(animated)
+
+		// this will be removed in viewWillDisappear
+		navigationController?.navigationBar.addGestureRecognizer(navBarTap)
+
     configureMessageMenu()
     configureMessageMenu()
 
 
     if #available(iOS 11.0, *) {
     if #available(iOS 11.0, *) {
@@ -121,6 +127,9 @@ class ChatViewController: MessagesViewController {
   override func viewWillDisappear(_ animated: Bool) {
   override func viewWillDisappear(_ animated: Bool) {
     super.viewWillDisappear(animated)
     super.viewWillDisappear(animated)
 
 
+		// the navigationController will be used when chatDetail is pushed, so we have to remove that gestureRecognizer
+		navigationController?.navigationBar.removeGestureRecognizer(navBarTap)
+
     let cnt = Int(dc_get_fresh_msg_cnt(mailboxPointer, UInt32(chatId)))
     let cnt = Int(dc_get_fresh_msg_cnt(mailboxPointer, UInt32(chatId)))
     logger.info("updating count for chat \(cnt)")
     logger.info("updating count for chat \(cnt)")
     UIApplication.shared.applicationIconBadgeNumber = cnt
     UIApplication.shared.applicationIconBadgeNumber = cnt

+ 0 - 6
deltachat-ios/Controller/SingleChatDetailViewController.swift

@@ -74,7 +74,6 @@ class SingleChatDetailViewController: ChatDetailViewController {
 		title = "Info"
 		title = "Info"
 		chatDetailTable.delegate = self
 		chatDetailTable.delegate = self
 		chatDetailTable.dataSource = self
 		chatDetailTable.dataSource = self
-
 	}
 	}
 
 
 	@objc override func editButtonPressed() {
 	@objc override func editButtonPressed() {
@@ -351,8 +350,3 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
 		}
 		}
 	}
 	}
 }
 }
-
-
-
-
-