How to prevent MessageUI SMS New Message view from underlapping status bar?
-
19-06-2021 - |
Question
A picture is worth a thousand words:
The app is setup for full screen by turning off the status bar in code. Every single UIViewController is full screen. They all behave as expected. No rotation either, the entire app stays in portrait. This works fine too.
The "New Message" interface animates up as expected but the status bar re-appears and, what is worst, the "New Message" view goes under it.
I am using the MessageUI framework to let the user send out SMS messages. Here's how the message compose interface is presented:
if([MFMessageComposeViewController canSendText])
{
MFMessageComposeViewController *msgvc = [[MFMessageComposeViewController alloc] init];
msgvc.body = @"SMS message content";
msgvc.recipients = [NSArray arrayWithObjects:@"1234567890", @"2345678901", nil];
msgvc.messageComposeDelegate = self;
[self presentModalViewController:msgvc animated:YES];
[msgvc release];
}
I tried playing with wantsFullScreenLayout
but it did absolutely nothing. I found some references to this problem through Google but no solutions.
Solution
Here's how I solved the problem:
I added this one line of code after presenting the MessageUI view controller to, I guess, re-hide the status bar:
[self presentModalViewController: msgvc animated:FALSE];
[[UIApplication sharedApplication] setStatusBarHidden:TRUE];
[msgvc release];
Even though the application starts-up in full screen mode (setup in code in the app delegate) MessageUI seems to require that the status bar be handled all over again.