I have a UITextField in my iPhone app. I know how to make the text field select all of its text, but how can change the selection? Say I wanted to select the last 5 characte
These both work for me:
[UITextField selectAll:self];
and:
UITextField.selectedRange = NSMakeRange(0, 5);
but only if the text field is the first responder. (In other words, only if the keyboard is showing.) So, you need to precede either of the select methods with this:
[UITextField becomeFirstResponder];
if you want the text to appear selected.