How to call a method when you click Finish in KeyBoard?

Do I want to call a method when the done button is pressed in the UITextField KeyBoard? Please help me...

+3
source share
2 answers

You don’t even need to implement a delegate. I prefer to use a nice, old-fashioned goal / action pattern to handle this. This can also lead to cleaner code if you have several ways to stop editing (for example, intercepting strokes outside the text box to cancel editing).

To use a target / action, just plug UIControlEventEditingDidEndOnExitin which is displayed as an event in Interface Builder Did End On Exit.

No mousse, no fuss. Much cleaner and easier than implementing a delegate.

+10
source

See the UITextFieldDelegate Protocol link . You probably want to implement the method – textFieldShouldReturn:on your deletion.

+6
source

Source: https://habr.com/ru/post/1741384/


All Articles