I have a view with multiple text fields and I want to do the same effect that the Contacts application does when you click on a text field would otherwise be hidden by the keyboard when it comes up. When I dismiss the keyboard I plan on moving the view back down properly.
I suspect that I do this by changing the Frame value, but I need this to be animated so that it isn’t jarring to the user.
Advice? Examples?
Wrapping your view in a UIScrollView is indeed the way to go. As well as on the
textFieldDidEndEditingdelegate, you could instead subscribe to theUIKeyboardDidHideNotificationandUIKeyboardDidShowNotificationand when you receive a notification that the keyboard did hide/show then scroll your view appropriately. I can post code examples for the keyboard notifications if you need it : )Edit
Figured I’d post the code anyway – someone might find it helpful:
You need to declare listeners for the notifications:
then your Action methods would look something like:
Edit 2
So if you’d like to remove the Observers when the view is destroyed, first you need to ensure you assign
NSObjects when adding the observers then use the following code to remove them:Hope that helps.