自定义cell上的textField输入完成后光标怎么自动跳到下一个

图片说明图片说明
电话号码输入完成后,会自动创建一个新的cell 然后不用点击textField就会出现光标可以直接输入电话号码

[_tableView reloadData];
[self performSelector:@selector(showKeyBoard) withObject:nil afterDelay:0.01];

  • (void)showKeyBoard { NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; HDFreeMessageCell *cell = [_tableView cellForRowAtIndexPath:indexPath]; [cell.customerPhoneTextField becomeFirstResponder]; }

你是输入完成后,不用按任何地方就自动跳到下一个输入框麽?这个貌似不行吧。好像只可以通过textField的代理方法,当按下return键的时候,
改变第一响应者。不多说,直接上代码:

## - (BOOL)textFieldShouldReturn:(UITextField *)textField { //

## if (textField == self.userNameTF) { // 当第一响应者为用户名输入框时,按下return键后,第一响应者变成密码输入框,以此类推

[self.passwordTF becomeFirstResponder];

}else if (textField == self.passwordTF) {

[self.surePasswordTF becomeFirstResponder];

}else if (textField == self.surePasswordTF) {

[self.emailTF becomeFirstResponder]; // 直到最后一个输入框,再按下return,可以执行你想要的操作。

}else {

// 这里执行你想要执行的操作,例如登陆或者保存等。

}

return YES;

}

如果你问的不是这个意思,就是我理解错了。不喜勿喷。