resignFirstResponder does not put away keyboard on UIModalPresentationFormSheet

I started to use a few view controllers inside of navigation controllers that are presented with the UIModalPresentationFormSheet style, and to my dismay discovered that the resignFirstResponder call does not make the keyboard disappear.

Apparently there is a reason for this, if you are interested you can look it up and get a full explanation. For my purposes, I was just happy to discover that overriding the disablesAutomaticKeyboardDismissal method and returning NO seems to do the trick. Basically, now when I need to present a navigation controller in this fashion, I alloc the navigation controller with the class of MyNavigationController instead of UIViewController. Here is the code for MyNavigationController.m:

#import "MyNavigationController.h"
@implementation MyNavigationController
- (BOOL)shouldAutorotate
    return YES;
- (NSUInteger)supportedInterfaceOrientations
    return UIInterfaceOrientationMaskAll;
- (BOOL)disablesAutomaticKeyboardDismissal
    return NO;

You will of course need to change the rotation methods to your own needs.

Today, I have a double BTW for you. Happy birthday to Joe Bonamassa, one of my favorite guitar players and all around performers. And on a sad note, one year ago today, Jeanne Cooper, the grand old dame of The Young and The Restless, passed away. The show has not been the same without her.

Leave a Reply