我有SigninController类,有两个textFields(作为Outlets)txtLogin和txtPassword:
当我填充txtLogin时,我调用[txtPassword becomeFirstResponder]将输入焦点传递给下一个字段(返回按钮在txtLogin中正常工作),但是返回按钮在txtPassword中不起作用,在这种情况下我无法解除键盘。我写错了什么?
示例代码:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == txtLogin) {
[txtLogin resignFirstResponder]; //Works as I think
[txtPassword becomeFirstResponder]; // txtPassword gets focus
} else {
[self signinClick]; //Never enter here
}
return YES;
}
- (IBAction)signinClick
{
NSLog(@"Signin Clicked");
[activityIndicator startAnimating];
[txtPassword resignFirstResponder];
..........
}
答案 0 :(得分:2)
您似乎忘记了正确设置 txtPassword 的委托。
答案 1 :(得分:0)
指定
urtextfieldobject.delegate =自我;
然后urViewcontroller.h
@interface urViewcontroller
确保他们两个