UIKeyboard does not hide when I touch outside the keyboard

user784625 picture user784625 · Jan 31, 2012 · Viewed 8.4k times · Source

I'm not figuering out a way to hide the keyboard when I touch outside the keyboard, is there any event that could hide the keyboard if I click outside the keyboard. Thanks

Answer

Tendulkar picture Tendulkar · Jan 31, 2012

In the ViewController.m write the touches began method.In that method write the resignFirstResponder

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
 [textField resignFirstResponder];

}