How to dismiss number pad keyboard by tapping anywhere

Solution 1:

Declaring the text field as instance variable or property if it isn't already and implementing a simple method like this:

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

will do just fine.

Solution 2:

Try this method,

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
   [self.view endEditing:YES];
}

Now tap anywhere and see keyboard will dismiss. :-)

Solution 3:

For Swift Use Below Code

override func touchesBegan(touches: NSSet, withEvent event: UIEvent)
 {
       textFiled.resignFirstResponder()
 }

Check out latest update on following Link