Hide your keyboard, when you tapped outside your UITextField

In your .m implementation file,


 - (void)viewDidLoad  
 {  
   [super viewDidLoad];  
     
   // hide your keyboard when you tap outside your textfield  
   // here i have only one textfield named mytestField  
     
     
   // get the ui gesture & set behave about textfield  
   UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]  
                   initWithTarget:self  
                   action:@selector(dismissKeyboard)];  
     
   [self.view addGestureRecognizer:tap];  
     
 }  
   
 // custom method : fire when you clicked outside the text field  
 -(void)dismissKeyboard {  
     
     
   [mytestField resignFirstResponder];  
   // you can same propyerty  
   // for more text field here.  
     
 }