任何人可以幫助我在這樣的情況:後becomeFirstResponder文本框不會將事件發送到委託
我SigninController類兩個文本框(如奧特萊斯)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];
..........
}
你設置了textfield的委託嗎? – kthorat