views:

41

answers:

2

Hi

I have noticed, in one of my views in an iPad app I am building the next button on the keyboard goes through all the UITextFields from left to right down the screen.

Is it possible somehow to make it go top to bottom then right, top to bottom?

So say I have to two long columns of text fields, I wan to go top to bottom not left to right, make sense?

Any help appreciated, thanks.

A: 

I don't think there is a way through IB, but you can do this way in code. You're not actually tabbing, you'd be using the return key.

Put this in your UITextField's delegate:

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
  BOOL shouldChangeText = YES;

  if ([text isEqualToString:@"\n"]) {
    // Find the next entry field
    BOOL isLastField = YES;
    for (UIView *view in [self entryFields]) {
      if (view.tag == (textView.tag + 1)) {
        [view becomeFirstResponder];
        isLastField = NO;
        break;
      }
    }
    if (isLastField) {
      [textView resignFirstResponder];
    }

    shouldChangeText = NO;
  }

  return shouldChangeText;
} 

Found here: http://iphoneincubator.com/blog/tag/uitextfield

christo16
A: 

You'll want to implement UITextFieldDelegate's - (BOOL)textFieldShouldReturn:(UITextField *)textField method. An example of how to use this method to control the order is in this question.

GregInYEG