bodacious
bodacious

Reputation: 6695

How can I keep this toolbar and text field above the keyboard?

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

Answers (2)

user1499077
user1499077

Reputation:

For make toolbar above your keyboard here is the most easy way..

Upvotes: 0

Damien Del Russo
Damien Del Russo

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

Related Questions