iPhone SDK:textFieldShouldReturn未被调用 [英] iPhone SDK : textFieldShouldReturn not being called
问题描述
我们正试图弄清楚如何让键盘隐藏起来,但我们在解决 textFieldShouldReturn
时遇到了问题。我们不确定为什么?
We're trying to figure out how to get the keyboard to hide, but we're having problems getting the textFieldShouldReturn
to fire. We are not sure why?
这就是已经完成的事情:
This is what has been done:
*。h
@interface MultiSalesViewController : UIViewController <UITextFieldDelegate>
*。c
txtCardNumber.delegate = self;
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField setUserInteractionEnabled:YES];
[textField resignFirstResponder];
return YES;
}
此外, textField
将它的委托设置为Interface Builder中的文件所有者。奇怪的是,viewController的 - (void)textFieldDidEndEditing:(UITextField *)textField
正在运行。
Also, the textField
has it's delegate set to Files Owner in Interface Builder. One odd thing, is that the viewController's - (void)textFieldDidEndEditing:(UITextField *)textField
is working.
有人可以评论如何隐藏键盘吗?
Can anyone comment as to how to get the hiding of the keyboard working?
推荐答案
我有完全相同的问题,因为我忘了将界面构建器中文本字段的委托设置为'文件所有者'。
I had the exact same issue and it was because I forgot to set the delegate for the text field in interface builder to 'files owner'.
这篇关于iPhone SDK:textFieldShouldReturn未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!