Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,715
6,305
I know that you can get the selectedRange for a UITextView, but I was wondering if you could somehow do the same for a UITextField?
 
No. UITextField is for simple text entry. Remember that the ability to select text at all is a recent addition to iOS.

In a UITextField, selecting text is just about editing that text. You'll need to use UITextView if you want the selecting of text to be more meaningful; that is, if you want to programmatically get that selection.
 
The workaround I'm using right now is I disabled my old UITextField, put a UITextView with the exact same frame on top of it, and set the backgroundColor property of UITextView to clearColor.

Just curious, does anyone know a way I could make it so that all the text goes on one line in my UITextView rather than wrapping to another line?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.