1

The search bar in the new Safari app shows the current URL highlighted when the search bar opens, so you can just type to replace it (this is also standard feature on almost every other OS). How to make this behaviour in our own UITextFields (or UISearchBar)?

The new clearsOnInsertion = YES setting seems like it should be the answer. But this does not visibly highlight the text, and also has other odd side effects like hiding the input cursor even after the selection is replaced by starting to type.

clearsOnBeginEditing=YES works fine, but this does not give the user the option to edit the existing entry if they want to.

And if you don't use either, the user has to first touch the Clear icon to do a new search.

wordy
  • 539
  • 5
  • 15
  • http://stackoverflow.com/q/1689911/900873 – Kevin Oct 26 '13 at 15:14
  • Thanks for the suggestion, but using (on a main thread) [T setSelectedTextRange:[T textRangeFromPosition:T.beginningOfDocument toPosition:T.endOfDocument]] where T is a UITextField in a search bar does work functionally in selecting the text, but it leaves the selection handles at the start and end showing. Any idea how to hide them? – wordy Oct 29 '13 at 23:07

0 Answers0