nathantannar4 / InputBarAccessoryView

A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments
MIT License
1.17k stars 232 forks source link

Focussing input text view before view appeared #17

Closed brod-ie closed 6 years ago

brod-ie commented 6 years ago

We've found self.bar.inputTextView.becomeFirstResponder() has to be called in or after viewDidAppear. Placing this call earlier in the view's lifecycle has no effect. We've also tried calling becomeFirstResponder() then this call to no avail.

We'd like the input text view to be focussed without animation immediately (akin to Messenger). How can we go about this?

nathantannar4 commented 6 years ago

Remember for an InputAccessoryView to be visible it's the ViewController itself that should be the first responder. Make sure canBecomeFirstResponder is overridden to true. Then by default the bar will be there when the ViewController is displayed. Also I don't think iOS will allow something to be the first responder when it's not visible which is why it has no effect. Is that what you mean by become available?

Sent with GitHawk

brod-ie commented 6 years ago

Yes we've tried putting becomeFirstResponder() early on too with no luck. Indeed canBecomeFirstResponder is overridden.

From this SO answer I've learnt to achieve this DispatchQueue.main.async needs to be used.

nathantannar4 commented 6 years ago

What are you trying to do? Have the keyboard raise when the user enters chat?

Sent with GitHawk