63

ビュー内の特定の UITextField にプログラムでフォーカスを割り当てるにはどうすればよいですか? いくつかのフィールドがあり、ビュー表示で、最初のフィールドではなく、特定のフィールドにカーソルを置きたいと思います。

4

3 に答える 3

149

Try doing this in viewWillAppear:

[desiredField becomeFirstResponder];

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

于 2009-06-18T20:26:07.147 に答える
5

Set the first responder for your view to be the text field. This can be done in IB.

于 2009-06-18T20:26:11.827 に答える