Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField focus

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.

like image 480
Robin Jamieson Avatar asked Jun 18 '09 20:06

Robin Jamieson


People also ask

What is UITextField?

An object that displays an editable text area in your interface.

How do you turn off focus on TextField?

Use the blur() method to remove the focus from an element, e.g. input. blur() . If you need to remove the focus from the currently active element without selecting it, call the blur method on the activeElement property - document.

What is a text field on Iphone?

A text field is a rectangular area in which people enter or edit small, specific pieces of text.


1 Answers

Try doing this in viewWillAppear:

[desiredField becomeFirstResponder]; 

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

like image 144
Alexi Groove Avatar answered Sep 21 '22 07:09

Alexi Groove