Can I automatically display the keyboard on a view push?

Discussion in 'iOS Programming' started by jchildress, Sep 3, 2008.

  1. jchildress macrumors member

    Jul 9, 2008
    I have a tableView in a navigation controller and when a specific cell\line is touched, it loads a simple view with only one UITextField in it. The text field will only need number inputs, so I'm using the num pad keyboard for the textField.

    I want the keyboard already loaded when the new view slides from right to left. There is nothing else to do in the view except input numbers into that textField. So my question is, how can I automatically display the keyboard when the new view is pushed?

    The best example of this can be found in the "Now Playing" app (the new version after is was added back into the app store). If you tap the "Settings" button on the tabBar, you'll see the "Location" cell. Tap that cell and the new view with the keyboard automatically displayed is exactly what I want to do.

    Also, for a bonus, how can I add the "X" circle to the right side of my textField like the one in the example mentioned above?
  2. Taum macrumors member

    Jul 28, 2008

    To do something when a view is pushed, you probably want to put some code in the view controller's viewWill/DidAppear: method.
    You can use the textfield's becomeFirstResponder method to ask it to become the first responder (and thus show the keypad).

    Quickly looking at the documentation for UITextField shows a clearButtonMode property. It really sounds like what you want ;)

Share This Page