How to make UITextField’s text selected programmatically ?

H

 

Hi,

For making UITextField’s text selected programmatically you need to set the UITextField’s delegate linke below :

txt.delegate = self;

and then put following code in textFieldDidBeginEditing

-(void)textFieldDidBeginEditing:(UITextField *)textField
        {
           [textField selectAll:self];

         }

And don’t forget to add delegate in .h

@interface ViewController : UIViewController <UITextFieldDelegate>

Hope this will help somebody.

Happy Coding !!!

 

About the author

minakshi.bhosale
By minakshi.bhosale

Category