问题描述
我想在UITextField KeyBoard中单击完成按钮时调用方法?请帮帮我......
I want to call a method when the done button is clicked in the UITextField KeyBoard? Please Help me...
推荐答案
甚至没有必要实现委托。我更喜欢使用好的,老式的目标/动作模式来处理这个问题。如果您有多种结束编辑方式(例如,拦截文本字段外的触摸以取消编辑),它还可以使代码更清晰。
It's not even necessary to implement the delegate. I greatly prefer using good, old-fashioned target/action pattern to handle this. It can also lead to cleaner code if you have multiple ways of ending editing (say, intercepting touches outside the text field to cancel editing).
要使用目标/操作,只需连接 UIControlEventEditingDidEndOnExit
,它在Interface Builder中显示为已退出结束
事件。
To use target/action, simply wire up UIControlEventEditingDidEndOnExit
, which shows up in Interface Builder as the Did End On Exit
event.
没有麻烦,没有大惊小怪。比实现委托更清洁,更容易。
No muss, no fuss. A lot cleaner and easier than implementing the delegate.
这篇关于点击KeyBoard中的完成按钮时如何调用方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!