问题标签 [uitextfielddelegate]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
684 浏览

ios - 当在 UIView 上按下另一个 UIButton 时,从实例变量中的 UITextField 捕获文本

我的 UIView 上有几个 UITextFields(在 UITableViewCells 内),带有“保存”UIButton。当用户单击“保存”按钮时,我想对 UITextFields 进行一些基本验证。

我已经覆盖了 textFieldDidEndEditing 以将我的每个 UITextField 数据保存到一个实例变量中;但是,如果用户在单击 UIKeyboard 的“返回”按钮或单击另一个 UITextField 之前单击保存按钮,则我最后一个 UITextField 中的数据永远不会保存到我的实例变量中,并且验证总是失败。

我正在寻找一种方法来触发“onBlur”(我知道那是 JS 的事情)类型的事件,以将 UITextField 中的字符串保存到我的实例变量中。

我查看了 UITextFieldDelegate 协议,但没有看到类似的内容。

有没有我可能会错过的方法?

0 投票
2 回答
523 浏览

ios4 - UITextField:无法输入文本,但表情符号、复制/粘贴和退格很好

我觉得这很奇怪,我创建了自己的继承自 UIAlertView 的类。在这个类中,我添加了一个 UITableView 作为子视图,单元格包含一个 UILabel 和一个 UITextField。

该类实现:UITableViewDelegate、UITableViewDataSource 和 UITextFieldDelegate,

在 cellForRowAtIndexPath 中,每个 cell.uiTxtField.delegate 都设置为 self。

在模拟器和真实的 iPhone 设备上都会发生以下情况:

  • 当我在 UITextField 中设置指针/手指时,键盘会弹出并 触发textFieldDidBeginEditing,这很好,符合预期。

  • 当我离开 UITextField 时,会触发textFieldDidEndEditing,这也很好,符合预期。

  • 但是当我开始输入文本时,光标停止闪烁,但没有向 UITextField 输入文本。

  • 我可以通过在包含文本的 UITextField 中按住指针/手指来复制和粘贴文本,选择复制然后将其粘贴到另一个 UITextField(或相同)中。

  • 退格工作正常。

  • 它还让我输入符号和表情符号等。

  • 我唯一不能输入的是字符/字母和数字

  • 返回按钮不会触发textFieldShouldReturn

由于触发了 textFieldDidBeginEditing 和 textFieldDidEndEditing 我假设我的委托设置很好,但我不明白为什么我不能输入文本以及为什么 textFieldShouldReturn 没有被触发。

可能是相关的。

任何帮助表示赞赏。

0 投票
1 回答
176 浏览

uitextfield - 输入值时将调用哪个 uitextfield 委托

在 UITextfield 中输入值以及离开该文本框的焦点之前将调用哪个委托。我想在输入焦点之前将 textfiled 的值与其他字符串进行比较。如果值不匹配,则清除文本框。

0 投票
1 回答
443 浏览

ios - textViewDidBeginEditing: within UIWebView not being called

i´ve created a subclass from UIView and put in a UIWebView. This displays a simple external website which contains just two textfields. The user can type in his email address and the verification.

I´ve already included the UIWebViewDelegate for the webViewDidFinishLoad: method. Additionally i´ve created a NSNotification for "UIKeyboardDidShowNotification".

Everything works, but when i select the second textfield, the first textfield automatically will be scrolled half out of the visible area. I´ve also included the UITextViewDelegate with - (void)textFieldDidBeginEditing:(UITextField *)textField but i get no NSLog from that delegate method.

Any help how i can get the frame of the selected textfield (within a UIWebView)? Thanks for any hints...

0 投票
3 回答
3682 浏览

iphone - 未调用函数 textFieldShouldBeginEditing

我知道有类似的问题,但这些答案对我没有帮助。我猜我还有其他错误。

我有一个 textView,我将它的委托设置为 self,但未调用相关函数。

这是代码:

在.h中:

以 .m 为单位:

0 投票
1 回答
980 浏览

iphone - 用户点击空格时 UITextField 突出显示文本

我有一个UITextField让用户像在stackoverflow中一样编写标签的方法。我真正想要的正是stackoverflow所做的,略有不同的是检测用户在键盘上的触摸空格按钮。好吧,stackoverflow立即搜索并显示结果。相反,我希望用户点击空格按钮。你们有什么想法,任何我可以从中受益的教程吗?我确定我将使用 UITextFieldDelegate 方法


-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string


但我不知道如何在用户开始点击另一个词之前突出显示这些词。

0 投票
2 回答
15065 浏览

ios - 如何使用 StoryBoard 在 iPad 上的 Popover 中显示 UIDatePicker?

我已经实现了在弹出框内显示日期选择器,以编程方式执行它,如UIPopover 中的 UIDatePicker所示。

但是我一直在尝试在界面生成器中执行此操作,我已经创建了一个名为 DatePickerViewController.m 的视图控制器,其中包含一个 DatePicker 及其相应的 IBoulet

StoryBoard 中 DatePickerViewController.m 中的 DatePicker

然后我需要在编辑生日文本字段时将其显示在弹出窗口中。所以我使用以下代码

而且我还在我当前的 ViewController 中导入了自定义 DatePickerViewController

但它没有显示弹出框内的日期选择器。

在此处输入图像描述

有人知道会发生什么吗?

0 投票
2 回答
220 浏览

iphone - 完成输入第一个uitextfield后如何自动计算第二个uitextfield

我有 2 个uitextfields(dollarPayTextField 和 rielPayTexField)。输入完成后dollarPayTextField,我想rielPayTextField自动计算。

例如,total: 10 $,当我在 DollarPayTextField 中输入 9 $ 时,我希望 rielPayTextField 显示 4000。那么,我该怎么做呢?这是我计算剩余的代码:

0 投票
2 回答
1739 浏览

ios - UITextField 委托不起作用

我有以下代码:

我还有以下委托功能:

但是,我注意到它永远不会被调用。我从界面构建器以及代码中设置了委托:[txtFields setDelegate:self];但似乎都不起作用。我还缺少其他什么吗?

0 投票
2 回答
194 浏览

iphone - 调用 textfieldshouldreturn 会导致调用异常

抛出的异常是:2012-09-21 00:46:56.885 Colors[3032:c07] -[UITextField value]: unrecognized selector sent to instance 0x718cce0 2012-09-21 00:46:56.887 Colors[3032:c07] *

实例 0x718cce0 是文本字段对象:

当我们返回 YES 时抛出异常,即使我们返回 NO。