Fixing Keyboard Hide When Reload UITableview iOS swift 5


Hello guys, If you ever worked with UITableview and UITextView or UITextfield. Like chat App or Comment app. You will face the keyboard will hide or in other word the keyboard close to down. And If we other famous apps like Instagram, it's not close but still exist even if we type and send messages.

And In this article I want to share with you guys, how to avoid it so you can easily make the keyboard always opened guys. I found many solution on the internet but some are bad because the keyboard have animation close and open again.

I used UITextview and customize it using GrowingTextView. Because I want to the Textbox change the height when user make a new line. So it will look like Whatsapp chat and It looks good. And I make the textbox above keyboard so it will make the user easily type and send messages.

The point is to make a new class custom and override canResignFirstResponder variable. So we can change it in our own class view controller. And that's good because that's the cause why the keyboard hide and show again. When you set canResignFirstResponder to false. The keyboard will not dismiss even you change page. So we need to set it back to false in viewWillDisappear method to make it close.

And this is the code you're waiting for guys.



This is the simple code that I want to share with you guys. It's pretty simple but it needs much time to figure it out this guys. I found the trick custom class on stackoverflow but implemantion I need to figure it out by my self.

So if you have any question please feel free to ask about everything it's ok.

Popular posts from this blog

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android