PDA

View Full Version : UITextField Keyboard Focus, ala Facebook App




chelsel
Jul 13, 2008, 05:38 PM
I'm creating a username/password view with two fields. I want the app to start with the cursor already blinking in the UITextField with the keyboard visible.

The Facebook app does this but I can't figure out how to get the same effect in my app (showing the keyboard immediately with the cursor in the first field).

Any ideas?

Thanks!



Enuratique
Jul 13, 2008, 08:30 PM
I'm creating a username/password view with two fields. I want the app to start with the cursor already blinking in the UITextField with the keyboard visible.

The Facebook app does this but I can't figure out how to get the same effect in my app (showing the keyboard immediately with the cursor in the first field).

Any ideas?

Thanks!

If you have IBOutlets for your UITextViews hooked up to your view controller, once the view has finished loading (perhaps in viewDidLoad) you can tell the username UITextView to become the first responder, which gives focus and displays the keyboard.


[usernameTextField becomeFirstResponder];


Try that and see if it works.

chelsel
Jul 14, 2008, 07:41 AM
That works. Thanks!

Cliff.