问题
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.
回答1:
Try doing this in viewWillAppear:
[desiredField becomeFirstResponder];
By making the field the first responder, it have focus and the keyboard will be displayed.
回答2:
Set the first responder for your view to be the text field. This can be done in IB.
来源:https://stackoverflow.com/questions/1014999/uitextfield-focus