MessageInputBar icon indicating copy to clipboard operation
MessageInputBar copied to clipboard

Can't make message input bar first responder?

Open AttilaTheFun opened this issue 5 years ago • 5 comments

I've tried calling: self.becomeFirstResponder() self.messageInputBar.becomeFirstResponder() self.messageInputBar.inputTextView.becomeFirstResponder()

From viewDidLoad, viewWillAppear, and viewDidAppear and I still can't get the keyboard to open automatically for my view controller. For normal text views, calling becomeFirstResponder() should automatically focus them and present the keyboard. What gives? Is there a workaround?

AttilaTheFun avatar Mar 14 '19 09:03 AttilaTheFun

Is the MessageInputBar visible? It's an input accessory view so the view controller needs to be the first responder to have the bar be presented

Sent with GitHawk

nathantannar4 avatar Mar 15 '19 06:03 nathantannar4

Yes the bar is visible. I overrode input accessory view and returned the bar, and overrode can become first responder and returned true. Once the controller is presented I can tap on the text view to activate it, but I can’t automatically focus it.

AttilaTheFun avatar Mar 15 '19 09:03 AttilaTheFun

You can call messageInputBar.inputTextView.becomeFirstResponder() from viewDidAppear(_ animated: Bool).

tanujkumar1640 avatar Mar 25 '19 20:03 tanujkumar1640

hello

what if bar is visible, I can type in it, but when send is pressed nothing happens

extension ViewController: MessageInputBarDelegate { func messageInputBar( _ inputBar: MessageInputBar, didPressSendButtonWith text: String) { print("ldldldld") let newMessage = Message( member: member, text: text, messageId: UUID().uuidString)

    messages.append(newMessage)
    inputBar.inputTextView.text = ""
    messagesCollectionView.reloadData()
    messagesCollectionView.scrollToBottom(animated: true)
}

}

lordKaos11 avatar Jun 10 '19 20:06 lordKaos11

Seems like this does the trick on latest:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    self.becomeFirstResponder()
    self.messageInputBar.inputTextView.becomeFirstResponder()
}

zkhalapyan avatar Jun 06 '20 18:06 zkhalapyan