Vince Yuan +

Can't dismiss keyboard on iPad (Solution inside)

Sometimes, you see the following code of dismissing keyboard not working on iPad but working on iPhone:

[_textField resignFirstResponder];

That's because a modal view in UIModalPresentationFormSheet mode on iPad ignores it by default.

To let it work, we need to add this method into your view controller:

  1. - (BOOL)disablesAutomaticKeyboardDismissal {
  2. return NO;
  3. }

If your view controller is in a navigation controller, add this method into your customised navigation controller.

  1. - (BOOL)disablesAutomaticKeyboardDismissal {
  2. return [self.topViewController disablesAutomaticKeyboardDismissal];
  3. }
blog comments powered by Disqus

Blogs

Projects