문제

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)

도움이 되었습니까?

해결책

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!

다른 팁

If you want to show the keyboard, you must take the text box from the mailer and then send the message becomeFirstResponder.

However, there is not straight forward way to do that. When you touch the box of the message, does the keyboard appear?

For others who may have come up with this keyboard issue in the MailComposer this solution worked for me:

  • Present the view then call "becomefirstResponder" on the same MFMailComposeViewController in the completion method.

    MFMailComposeViewController* mailCon = [[MFMailComposeViewController alloc] init]; [self presentViewController:mailCon animated:NO completion:^{ [mailCon becomeFirstResponder]; }];

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top