After becomeFirstResponder textField doesn't send events to delegate
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
精彩评论