nathantannar4 / InputBarAccessoryView

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

InputBarAccessoryView & inputTextView disappeared after searchbar has focused #252

Open ismaelShabrawy opened 10 months ago

ismaelShabrawy commented 10 months ago

Dears,

Now the app have view controller has the tableview to show realtime chat message and we added InputBarAccessoryView and implement it and it working .

but we have a search bar when this search bar get focus and user type in the InputBarAccessoryView and the input text disappear from the screen and even in the debug view hierarchy as the attached images:

before the search bar get focus the input text appears :

Screenshot 2023-10-30 at 12 54 14 PM

after the search bar focused and the user type :

Screenshot 2023-10-30 at 12 54 52 PM

so I need to show the InputBarAccessoryView again after the user finish searching

I used this before focus searchbar

        self.messageInputBar.resignFirstResponder()
        self.messageInputBar.inputTextView.resignFirstResponder()

and this after the user end search or clicks the cancel button:

            self.messageInputBar.becomeFirstResponder()
            self.messageInputBar.inputTextView.becomeFirstResponder()

if let window = UIApplication.shared.delegate?.window {
                    window?.makeKey()
                    window?.becomeFirstResponder()
                }

and still not visible to the user

Thanks

nathantannar4 commented 10 months ago

When using InputBarAccessoryView as an inputAccessoryView of a UIViewController, you should be making the view controller the first responder. It is expected that when it is not the first responder, the input bar is hidden.

https://developer.apple.com/documentation/uikit/uiresponder/1621119-inputaccessoryview

gerchicov-vg commented 1 month ago

Possibly my issue is similar: https://github.com/nathantannar4/InputBarAccessoryView/issues/266