In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear: In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear: ios ios

In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear:


Try calling it in the cellForRowAtIndexPath method after creating the cell, or in the viewWillAppear of the tableViewCell that contains that textField.

If that gives you the same result and you still want the keyboard to appear before, I would use a "fake" textField to display the keyboard in the beginning. My guess is that your textField hasn't been added before the viewWillAppear.


I tried your code exactly, iOS6 & in viewWillAppear and it seemed to work fine.Your trying to have the keyboard already displayed when you push over to a different view am i correct?


I'm currently writing my own Input Form Kit and struggled a few hours with this problem.After finding out, that my coding was fine, I found this question pointing to a possible glitch in iOS 6 and worked on a solution for this.

If you have (or create) a custom UITableViewCell, an easy solution would be to just subclass - (void) layoutSubviews; and check if the cell's UITextField should be the first responder (i.e. by checking if the text field is the same as the focused field set in your delegate).If so, just call - (BOOL) becomeFirstResponder; on your UITextField (again).

This is definitely a better solution than creating a "fake" UITextField ;)