title: How to set focus to next uitextfield in iPhone?
body: <p>I have 8 uitextfields that are for a password. Each textfield contains one letter from password. When I type one letter and after that when I press the 2nd key then focus moves to next textfield. But I want that, as soon as I finished typing first character, the focus should move to the next text field without pressing other key or pressing tab key. How can I do that? Any tutorial of sample code for that? The code I have used is as below.</p>
  
  <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
      [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextFieldTextDidChangeNotification object: nil];
      // Try to find next responder
  
      UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
      if (nextResponder) {
          // Found next responder, so set it.
          //nextTag += 1;
          [nextResponder becomeFirstResponder];
          if ([nextResponder tag] == 308) {
              //[self performSelector:@selector(checkPassCode) withObject:nil afterDelay:0.0];
              [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(checkPassCode) userInfo:nil repeats:NO];
              lastResponder = nextResponder;
          }
          return YES;
      } else {
          [textField resignFirstResponder];
          return NO;
      }
  }
  
  
  -(void) keyPressed: (NSNotification*) notification
  {
      nextTag += 1;
      [[NSNotificationCenter defaultCenter] removeObserver: self name:UITextFieldTextDidChangeNotification object: nil];
  }
  </code></pre>