UITextField Keyboard Focus, ala Facebook App

Discussion in 'iPhone/iPad Programming' started by chelsel, Jul 13, 2008.

  1. macrumors 6502

    Joined:
    May 24, 2007
    #1
    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!
     
  2. macrumors 6502

    Joined:
    Apr 28, 2008
    #2
    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.

    Code:
    [usernameTextField becomeFirstResponder];
    
    Try that and see if it works.
     
  3. thread starter macrumors 6502

    Joined:
    May 24, 2007
    #3
    That works. Thanks!

    Cliff.
     

Share This Page