Search code examples
iphoneobjective-ciosios6mfmailcomposer

Missing keyboard in MFMailComposeViewController


I've got this code working well for months (on iOS 5.1), but I didn't check it for a long time and now (probably iOS 6.0 issue) I've noticed that my MFMailComposeViewController doesn't show the keyboard even when focusing textfields like message body or recipients.

The strange thing is that it reacts on taps, so i can set cursor on 'To' or 'Subject' and the cursor appears, or I'm able to hold the tap to make the zooming glass pop up. But no keyboard :(

SCREENSHOT OF THIS

Here's the code I'm using:

MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;        
[self presentModalViewController:mailer animated:YES];

I've been searching a lot about this and found something that deals with
[self resignFirstResponder] or [mailer becomeFirstResponder], but it didn't work.

If I add this code before or after presenting controller

NSLog(@"mailer become %d", [mailer canBecomeFirstResponder]);

It shows 0, however, the

NSLog(@"self resign %d", [self resignFirstResponder]);

shows 1, but it was 0 too before i added the

- (BOOL)canResignFirstResponder {
    return YES;
}

Docs say it should return YES by default, so it's double strange.

If I create an empty project with such code it works well, but I can't really do this because my current project is quite huge. Any help would be appreciated, getting stuck here...

Tested both on iPhone and iOS Simulator (both deployment target 5.1 and 6.0)


Solution

  • Just LOL. The problem was with the

    [UIApplication sharedApplication] delegate] window] setWindowLevel:UIWindowLevelStatusBar + 1]
    

    somewhere in my app. Seems like they changed keyboard windowLevel in iOS 6, so that now it's behind. I'm quite lazy to do so, but it would be interesting to know exact windowLevel of the keyboard window :)
    Be careful with that!

    Thanks to everyone for helping anyway!