How to call a method when the Done Button in the KeyBoard is Clicked?
I want to call a method when the done button is clicked in the UITextField KeyBoard? Please Help me…
2 Solutions Collect From Internet About “How to call a method when the Done Button in the KeyBoard is Clicked?”
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.
- topLayoutGuide in child view controller
- How to add UISearchBar to NavigationBar through the storyboard in iOS
- Add a Done button within a pop-up datePickerView in Swift?
- Are there new device identifiers in iOS 10?
- What's the advantage of #selector update in Swift 2.3?
- How do I localize UIImagePickerController
- How to reliably install and setup Quick test framework on Xcode 8?
- Difference between Keychain and NSUserDefault?
- What is the best way to handle response from Alamofire for a TableView in Swift using separate classes?
- Passing data between two controllers using storyboards
- UITableview , dynamically section & rows
- Call a class method from within that class
- What is a non-fragile ABI?
- UIScrollView scroll event blocks UIView animation
- How to change the default View Controller that is loaded when app launches?