title: How do I set the next text field in focus for editing when the user hits return?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1347779/how-to-navigate-through-textfields-next-done-buttons">How to navigate through textfields (Next / Done Buttons)</a><br>
    <a href="https://stackoverflow.com/questions/9540500/ios-app-next-key-wont-go-to-the-next-text-field">iOS app “next” key won’t go to the next text field</a>  </p>
  </blockquote>
  
  
  
  <p>I have two text fields in my view and I'd like the cursor to move from the email text field to the password text field when the user hits the return key.  If the password text field is the one in focus, I'd like the keyboard to hide.  Here's what I currently have, but it doesn't work...</p>
  
  <pre><code>- (BOOL)textFieldShouldReturn:(UITextField *)textField {
      return YES;
  }
  
  - (void)textFieldDidEndEditing:(UITextField *)textField {
      if(textField == self.emailTextField) {
          [self.passwordTextField becomeFirstResponder];
      }
  
      else if (textField == self.passwordTextField) {
          [textField resignFirstResponder];
      }
  }
  </code></pre>
  
  <p>What am I missing?  Thanks so much in advance for your wisdom!</p>