I have a view controller whose viewDidLoad method invokes becomeFirstResponder on a textfield (email) contained within its associated view:
-(void) viewDidLoad {
[email becomeFirstResponder];
}
This view controller is loaded by pushing it onto the navigation controller’s stack. The above code works great for the first time round.
However, later on in the application when I want to return to this view controller the keyboard doesn’t appear automatically (this is when using popToViewController:animated). Instead the user has to manually set the focus to a textfield for the keyboard to appear…My guess is viewDidLoad isn’t invoked after popToViewController:animated has loaded the relevant view controller?
How do I resolve this issue?
Try putting it in viewWillAppear. viewDidLoad will usually only run once unless you specifically tell it otherwise.