简体   繁体   English

UITextField自定义InputView-如何获取textFieldShouldReturn触发?

[英]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.

相关问题 如何使用自定义inputView获取UITextFieldDelegate.shouldChangeCharactersInRange? - How can I get UITextFieldDelegate.shouldChangeCharactersInRange to fire with custom inputView? 如何判断哪个UITextField刚刚触发了textFieldShouldReturn回调? - how do I tell which UITextField just triggered the textFieldShouldReturn callback? UITextField 的自定义 inputView,如何将输入直接返回到文本字段? - Custom inputView for UITextField , how do I direct input back to the text field? 从inputView获取UItextField - Get UItextField from inputView 具有自定义 inputView (VoiceOver) 的 UITextField 可访问性 - Accessibility for UITextField with custom inputView (VoiceOver) 如何获取自定义文本视图的inputView? - How can I get custom Text View's inputView? 如何模拟在 textFieldShouldReturn 上单击 NavigationLink? - How do I emulate the clicking of a NavigationLink on textFieldShouldReturn? iOS UITextField-解雇自定义inputView - iOS UITextField- dismissing custom inputView UITextField不将datePicker.date显示为inputview - UITextField do not display datePicker.date as inputview 无法在自定义UITableCell中从UITextField调用textFieldShouldReturn - Having trouble calling textFieldShouldReturn from a UITextField within a custom UITableCell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM