selectedRange for a UITextField?

Discussion in 'iOS Programming' started by ArtOfWarfare, Sep 5, 2011.

  1. ArtOfWarfare macrumors G3


    Nov 26, 2007
    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?
  2. jiminaus macrumors 65816


    Dec 16, 2010
    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.
  3. ArtOfWarfare thread starter macrumors G3


    Nov 26, 2007
    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?

Share This Page