Question

I'm trying to make the text in a UITextField select when the user taps the field to begin editing. The idea is that normally, they will want to erase the entire field first, so this saves the step of having to double tap and select all.

.h

- (IBAction)urlEditingDidBegin: (id)sender;

.m

- (IBAction)urlEditingDidBegin:(id)sender
{
    NSLog(@"Select Contents");

    [sender setText:@"Why isn't this working"];
    [sender selectAll:self];
}

In interface builder I wired my UITextField's "Editing Did Begin" event to the file's owner and connected it to my urlEditingDidBegin method.

When I tap the UITextField, the text in the field changes to "Why isn't this working" which proves the method is firing and that the sender is correct, however the text does not select.

What am I doing wrong?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top