Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle Keyboard Done pressed event on Iphone

I am moving my view when a text field is pressed in order to get proper view when keyboard appears. Now, when the Done keyboard button is pressed, I would like to return the view to its initial state. How do I handle an action when the done keyboard button is pressed?

like image 338
Ruthy Avatar asked Jun 26 '10 12:06

Ruthy


1 Answers

The proper way to do this is to observe to the notifications UIKeyboardDidShowNotification and UIKeyboardDidHideNotification as detailed in Apple's documentation.

If you want to know when the Done button has been pressed, implement

- (BOOL)textFieldShouldReturn:(UITextField *)textField

In your delegate. It should be called when the return button is pressed. See API documentation for more details.

like image 65
freespace Avatar answered Sep 30 '22 08:09

freespace