Reputation: 6695
I have a UIView that contains a UITableView and a toolbar with a UITextField
When I tap the text field, the keyboard covers it over.
I want to keep the toolbar above the keyboard, just like in the native Messages app. Is it better to add this toolbar as the last cell in the TableView or animate the toolbar's Y position to move up and down when it's TextField becomes first responder?
Any advice appreciated.
Upvotes: 0
Views: 887
Reputation: 1048
The tableView should scroll to display the footer if it is firstResponder, so that might be a good place to tuck the toolbar.
Otherwise if you are manually moving your toolbar you can use notifications to manage the appearance. Here is from the Xcode docs:
Keyboard Notifications
When the system shows or hides the keyboard, it posts several keyboard notifications. These notifications contain information about the keyboard, including its size, which you can use for calculations that involve moving views. Registering for these notifications is the only way to get some types of information about the keyboard. The system delivers the following notifications for keyboard-related events:
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
The tableView footer is probably less code.
Good luck,
Damien
Upvotes: 1