tags:

views:

1344

answers:

1

I use the "Next" value for the "Return Key" to get the Next button in place of the Done button, but (obviously) pressing it doesn't automatically move to the next UITextField in my view.

What's the right way to do this? On a larger topic, what are some tips for properly building forms in the iPhone SDK?

+6  A: 

Make some object the first text field's delegate, and implement the - (BOOL)textFieldShouldReturn:(UITextField *)textField method; in that, call the second text field's -becomeFirstResponder. Returning YES from that will make the text field perform its default behavior for the return button – I think that's generally sending its action message. If you don't have anything added as a target of that action, it doesn't really matter what you return.

Noah Witherspoon
...and if you are in the last UITextField you should call resignFirstResponder to hide the keyboard.
Dan J
is this a totally different way than explained here (http://stackoverflow.com/questions/467881/how-do-you-change-the-uicontrol-with-focus-on-iphone) or will both work just as well?
HollerTrain
Either will work. My answer uses the delegation system, Brad's the target-action stuff.
Noah Witherspoon