我有两个文字字段。首先我在键盘上设置“下一步”按钮,但按钮“完成”正在第二个字段上工作。我写了这段代码。
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.loginField) {
[theTextField resignFirstResponder];
} else if (theTextField == self.passField) {
[self.passField becomeFirstResponder];
}
return YES;
}
也许我错了。
答案 0 :(得分:0)
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
if(textField == self.loginField)
{
[self.passField becomeFirstResponder];
}
else if(textField == self.passField)
{
[textField resignFirstResponder];
}
return YES;
}
In xib, select LoginField - Return key set as "Next", Select PassField - Return key as "Done"/"Next".