How to make UITextField's text selected programmatically
iphone, objective-c, uitextfield
Solution
Please check where you have placed it... Try putting the code above in
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField selectAll:self];
}
And also txt must be UITextField. Also do not forget to set the delegate for txt as
txt.delegate = self;
where you have declared it and add UITextFieldDelegate in .h as
@interface ViewController : UIViewController <UITextFieldDelegate>
This will definitely work....It worked for me..
Problem
I want to select all text from the UITextField selected when i start editing. I tried the below code but this doesn't work. ``` [txt selectAll:self]; ```