在iOS中未调用textFieldShouldReturn [英] textFieldShouldReturn not being called in iOS

查看:67
本文介绍了在iOS中未调用textFieldShouldReturn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试找出如何隐藏键盘,但是在触发textFieldShouldReturn时遇到了问题.为什么?

We're trying to figure out how to get the keyboard to hide, but we're having problems getting the textFieldShouldReturn to fire. Why?

这已完成:

*.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 its delegate set to Files Owner in Interface Builder. One odd thing, is that the viewController's - (void)textFieldDidEndEditing:(UITextField *)textField is working.

如何使隐藏的键盘正常工作?

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'.

这篇关于在iOS中未调用textFieldShouldReturn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆