开发者

How to call a method when the Done Button in the KeyBoard is Clicked?

开发者 https://www.devze.com 2022-12-27 15:34 出处:网络
I want to call a method when the done button i开发者_运维知识库s clicked in the UITextField KeyBoard? Please Help me...It\'s not even necessary to implement the delegate.I greatly prefer using good, o

I want to call a method when the done button i开发者_运维知识库s 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).

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.


See the UITextFieldDelegate Protocol reference. You probably want to implement the – textFieldShouldReturn: method in your delegate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号