Using the notification center, as described in How can I get a textDidChange (like for a UISearchBar) method for a UITextField?, allows you to get a notification when text in an iOS UITextField changes. I didn’t see a similar notification for selection changes. What’s the best way to detect and respond to changes in the selection for a UITextField?
Using the notification center, as described in How can I get a textDidChange (like
Share
Wire up a method using target/action to the
UIControlEventEditingChangedcontrol event on your instance ofUITextField. This can be done in the interface builder or in code by adding a target/action pair to the text field and then implementing the specified method.UITextFieldalso declares aUITextFieldDelegateprotocol with methods that you can implement in your class to be notified of changes to an instance ofUITextField. I recommend that you become comfortable with delegation as it is a common pattern in the Cocoa framework.UITextFieldDelegate Class Reference