[英]UITextField Custom InputView - How do I get textFieldShouldReturn to fire?
I have created a custom inputView and have a Done button. 我创建了一个自定义的inputView并有一个“完成”按钮。 Does anyone know how I can wire the done button up to work the same as a return key on the built in keyboard. 有谁知道我如何将完成的按钮连接起来,使其与内置键盘上的返回键相同。
I basically need to get the textFieldShouldReturn method to fire for a UITextField. 我基本上需要获取textFieldShouldReturn方法来触发UITextField。
I know I can call resignFirstResponder on the textfield, but this does not fire the textFieldShouldReturn method. 我知道我可以在文本字段上调用resignFirstResponder,但这不会触发textFieldShouldReturn方法。
If it's a custom input view, and a custom "Done" button, why do you need to use the text field delegate methods? 如果是自定义输入视图和自定义“完成”按钮,为什么需要使用文本字段委托方法? You can wire the done button to your own action. 您可以将完成按钮连接到自己的操作。
If you have some common code in your textFieldShouldReturn
method this could be moved out to another method which can be called from the delegate method and your new action. 如果您的textFieldShouldReturn
方法中包含一些通用代码,则可以将其移到另一个方法中,该方法可以从委托方法和新操作中调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.