I have a table with UITextFields, and I want to make it so that when a textfield is selected, the current info is cleared (to allow new input), but if the user decides (after selecting) that they don’t want to change it, I want them to be able to click elsewhere and the data from before reappears in the textfield.
Is there an easy way to do this?
A good way to do this that’s nice and user friendly is to use the
placeholderproperty. Set up your viewController as the textfield’s delegate (as described by Andeh) then add the following code:And you’re done. If you have multiple
UITextFields on the page and you don’t want this behaviour for all of them you can add a check to the methods above.