Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make message input bar first responder? #24

Open
AttilaTheFun opened this issue Mar 14, 2019 · 5 comments
Open

Can't make message input bar first responder? #24

AttilaTheFun opened this issue Mar 14, 2019 · 5 comments

Comments

@AttilaTheFun
Copy link

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?

@nathantannar4
Copy link
Member

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

@AttilaTheFun
Copy link
Author

AttilaTheFun commented Mar 15, 2019

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.

@tanujkumar1640
Copy link

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

@lordKaos11
Copy link

lordKaos11 commented Jun 10, 2019

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)
}

}

@zkhalapyan
Copy link

zkhalapyan commented Jun 6, 2020

Seems like this does the trick on latest:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants