I add a UITapGestureRecognizer into messagesCollectionView in my custom viewcontroller which extends MessagesViewController.
I also return true in delegate method of UIGestureRecognizerDelegate.
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {`
return true
}
The above method is called but my selector method of above tap gesture is not called.
Here is my code:

The same question, solutions, that you gave earlier, don't work in 3.4.2
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
i use 3.1.0 also cannot hide keyboard when tap on
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
You can leverage the existing gesture recognizer method in MessagesCollectionView by creating your own custom class that inherits MessagesCollectionView. Add a simple delegate and you can detect any taps in messagesCollectionView without interrupting the MessageCellDelegate methods.
protocol MessagesCollectionViewDelegate: AnyObject {
func didTap()
}
class ChatMessagesCollectionView: MessagesCollectionView {
weak var messagesCollectionViewDelegate: MessagesCollectionViewDelegate?
override func handleTapGesture(_ gesture: UIGestureRecognizer) {
super.handleTapGesture(gesture) // Required for MessageCellDelegate methods to work
messagesCollectionViewDelegate?.didTap()
}
}
Now just implement the delegate method in your MessagesViewController and hide the keyboard when the delegate is triggered.
class ChatMessagesViewController: MessagesViewController {
override func viewDidLoad() {
self.messagesCollectionView = ChatMessagesCollectionView()
(self.messagesCollectionView as? ChatMessagesCollectionView)?.messagesCollectionViewDelegate = self
super.viewDidLoad()
}
}
extension ChatMessagesViewController: MessagesCollectionViewDelegate {
func didTap() {
self.messageInputBar.inputTextView.resignFirstResponder()
}
}
extension YourMessageVC: MessageCellDelegate {
func didTapBackgroud(in cell: MessageCollectionViewCell) {
self.messageInputBar.inputTextView.resignFirstResponder()
}
}
Examples above should work 馃憤