在afterFirstResponder之后,textField不会向委托发送事件

时间:2011-07-11 16:19:43

标签: iphone objective-c textfield becomefirstresponder resignfirstresponder

在这种情况下,任何人都可以帮助我:

我有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];
    ..........
}

2 个答案:

答案 0 :(得分:2)

您似乎忘记了正确设置 txtPassword 委托

答案 1 :(得分:0)

指定

urtextfieldobject.delegate =自我;

然后urViewcontroller.h

@interface urViewcontroller

确保他们两个