title: In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear:
body: <p>In iOS 5.1 and iOS 5.0 it works, but in iOS 6.0 the keyboard does not show.</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
      UITextField *textField = self.emailAddressTextField;
      [textField becomeFirstResponder];
  }
  </code></pre>
  
  <p>For now I moved the logic to <code>-viewDidAppear:</code>.</p>
  
  <pre><code>// This works but is not desirable.
  - (void)viewDidAppear:(BOOL)animated
  {
      [super viewDidAppear:animated];
      UITextField *textField = self.emailAddressTextField;
      [textField becomeFirstResponder];
  }
  </code></pre>
  
  <p>This works, but is not desirable. The keyboard slide-up animation is shown after the view loads.</p>
  
  <p>I want to keyboard to be present as the slide-to-left animation presents the view being loaded in the navigation controller.</p>
  
  <p>Do anyone know how to have the keyboard loaded as the view appears in iOS 6?</p>
  
  <p><em><strong>update</em></strong></p>
  
  <p>Based on @Duck's feedback, I did a little more testing. This seems to be specific to UITextFields contained in UITableViewCells.</p>
  
  <p>Does anyone have any suggestions?</p>
  
  <p><em><strong>FIRST SOLUTION</em></strong></p>
  
  <p>So a full description. This is a table view with two static cell (email and password). There is a login button in a view that is assigned the table footer view. The two cells have have a text field in them and are of a custom type SICOTextFieldCell.</p>
  
  <p>My solution was to put a fake text field behind the login button (in the table footer view).</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
      UITextField *textField = self.SICO_fakeTextField;
      [textField becomeFirstResponder];
  }
  
  - (void)viewDidAppear:(BOOL)animated
  {
      [super viewDidAppear:animated];
      UITextField *textField = self.SICO_emailAddressTextField;
      [textField becomeFirstResponder];
  }
  </code></pre>
  
  <p><em><strong>NEW SOLUTION</em></strong></p>
  
  <p>Based on the answer by @stm, I came up with a new (superior?) solution.</p>
  
  <p>My solution was to call <code>-selectRowAtIndexPath:animated:scrollPosition:</code>. <code>-[SICOTextFieldCell setSelected:animated:]</code>, which is a custom table view cell, calls <code>[self.textField becomeFirstResponder]</code> which magically draws the keyboard correctly. It's still a hack, but it's a cleaner hack.</p>
  
  <pre><code>@interface SICOLogInViewController ()
  @property (readonly, nonatomic) UITextField *SICO_emailAddressTextField;
  @property (readonly, nonatomic) UITextField *SICO_passwordTextField;
  @end
  
  @implementation SICOLogInViewController
  
  - (IBAction)logIn
  {
      // Controller Details
  }
  
  #pragma mark Private
  
  - (UITextField *)SICO_textFieldForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      SICOTextFieldCell *cell = (SICOTextFieldCell *)[self.tableView cellForRowAtIndexPath:indexPath];
      return cell.textField;
  }
  
  #pragma mark View lifecycle
  
  - (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
      [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
                                  animated:NO scrollPosition:UITableViewScrollPositionTop];
  }
  
  #pragma mark UITextFieldDelegate
  
  - (BOOL)textFieldShouldReturn:(UITextField *)textField
  {
      switch (textField.returnKeyType) {
          case UIReturnKeyGo:   [self logIn];                                       break;
          case UIReturnKeyNext: [self.SICO_passwordTextField becomeFirstResponder]; break;
          default: break;
      }
      return YES;
  }
  
  #pragma mark Properties
  
  - (UITextField *)SICO_emailAddressTextField
  {
      return [self SICO_textFieldForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
  }
  
  - (UITextField *)SICO_passwordTextField
  {
      return [self SICO_textFieldForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
  }
  
  @end
  </code></pre>