UITextField focus

Robin Jamieson picture Robin Jamieson · Jun 18, 2009 · Viewed 43.3k times · Source

How can I programmatically assign focus to a specific UITextField in a view? I have several fields and on view display, I'd like to put the cursor on a specific field, not the first one at top.

Answer

Alexi Groove picture Alexi Groove · Jun 18, 2009

Try doing this in viewWillAppear:

[desiredField becomeFirstResponder];

By making the field the first responder, it have focus and the keyboard will be displayed.