UItextField委托不起作用 [英] UItextField Delegate not working

查看:84
本文介绍了UItextField委托不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPad应用程序中,我有两个文本字段。一个显示正常的默认文本字段,另一个显示选择器作为其输入视图。

In my iPad app I have two textfields. One displays the normal, default textfield and the other should display a picker as its input view.

问题是,一旦我使用 txt1 显示默认键盘然后当我触摸第二个textField时, txt1 键盘保持可见。

Problem is, once I use the txt1 which displays default keyboard and then when I touch the 2nd textField the txt1 keyboard is staying visible.

我还在显示选择器时写了 [txt1 resignFirstResponder]; [txt2 resignFirstResponder];

I have also written [txt1 resignFirstResponder]; [txt2 resignFirstResponder]; while displaying the picker.

我检查了txt1 IBOutlet 连接和委托分配,这些似乎是正确的。

I have checked the txt1 IBOutlet connection and the delegate assignment, those seem to be correct.

我缺少什么?

推荐答案

编写以下代码:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
   if(textField == txt1)
   {
       return YES;
   }
   else
   {
       return NO; // Write the code for displaying UIPickerView instead of the Keyboard.
   }
}

希望这可以解决您的问题..... 。

Hope this might solve your issue......

这篇关于UItextField委托不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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