Satyam
Satyam

Reputation: 15894

iphone MFMessageComposeViewController, status bar problem

I'm using the following code to show in-app sms. My app don't have a status bar. (I'm using 320x480 pixels screen in portrait view)

if ([MFMessageComposeViewController canSendText]) 
    {
        MFMessageComposeViewController* msgController = [[MFMessageComposeViewController alloc] init];
        msgController.recipients = [NSArray arrayWithObject:self.globalSMS];
        msgController.messageComposeDelegate = self;
        [self presentModalViewController:msgController animated:YES];
        [msgController release];
    }

This is working good to display the message view controller. (But status bar comes back, which is not necessary for me to show) But the problem is that when I click "Cancel" or "Send", after going back to application, I am seeing white space on the top (in position of status bar) of the screen. And status bar is hidden. Why is it happening when my status bar is set as hidden in app delegate. How to get rid of white space after showing the in-app sms view.

Upvotes: 1

Views: 2932

Answers (4)

Hide the status bar after you modal presented the message controller. Something like this:

controller.wantsFullScreenLayout = NO;
[self presentModalViewController:controller animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];

Also Answered here: MFMessageComposeViewController not properly displayed

Upvotes: 7

user1053839
user1053839

Reputation: 390

        MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
        if([MFMessageComposeViewController canSendText]){
            controller.body = @"MessageText!!!";
            controller.recipients = [NSArray arrayWithObjects:@"123"];
            controller.messageComposeDelegate = self;
            controller.wantsFullScreenLayout = YES;
            [self presentModalViewController:controller animated:YES];
        }

Upvotes: 0

RandyMcMillan
RandyMcMillan

Reputation: 55

The issue is in portrait view. From what I am seeing if the MFMessageComposeViewController loads in landscape the space isn't there. Then if the orientation changes to portrait the layout is corrected and the space isn't present in portrait.

Note When in landscape the MFMessageComposeViewController is presented by sliding from left to right. I believe that the way the view is presented holds to key to fixing the issue.

Upvotes: 0

Satyam
Satyam

Reputation: 15894

I found the answer. We've to set in view controller's viewDidLoad method:

self.wantsFullScreenLayout = YES;

Upvotes: 2

Related Questions