开发者

After becomeFirstResponder textField doesn't send events to delegate

开发者 https://www.devze.com 2023-03-19 05:10 出处:网络
can anybody help me in such situation: I have SigninController class with two textFields (as Outlets) txtLogin and txtPassword:

can anybody help me in such situation:

I have SigninController class with two textFields (as Outlets) txtLogin and txtPassword:

when I filled txtLogin, I call [txtPassword becomeFirstResponder] to pass input focus to next field (return button works fine in txtLogin), but Retur开发者_开发知识库n button doesn't work in txtPassword and I can't dismiss keyboard in this case. What did I write wrong ?

Example code:

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


It seems you have forgot to set the delegate of txtPassword correctly.


specify

urtextfieldobject.delegate=self;

then urViewcontroller.h

@interface urViewcontroller

make sure both of them

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号