我有多个 UITextField 并试图单击下一步以在它们之间切换。我已经为每个标签设置了 1-4。当我运行我的代码时,它会移动到第二个,但不会移动到第三个。如果我跳 textField.tag + 2; 它会跳到第三个字段,但不会从那里继续前进。这是我的代码:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
theScrollView.frame = CGRectMake(theScrollView.frame.origin.x, theScrollView.frame.origin.y,
theScrollView.frame.size.width, theScrollView.frame.size.height + 265 - 50); //resize
NSInteger nextTag = textField.tag + 1;
// Try to find next responder
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
// Found next responder, so set it.
[nextResponder becomeFirstResponder];
} else {
// Not found, so remove keyboard.
[textField resignFirstResponder];
}
return NO; // We do not want UITextField to insert line-breaks.
}