2

I'm using MFMessageComposeViewController in order to show the SMS send interface.

My app uses full screen, the status bar is hidden by settings in plist file (Status bar is initially hidden = YES).

When I show the message composer with:

+(void)composeSMS:(id)sender
{
    if (![MFMessageComposeViewController canSendText]) return;

    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];

    controller.wantsFullScreenLayout = YES;

    controller.messageComposeDelegate = sender;
    [controller setBody:@"He descubierto un App estupenda! . "];
    [controller setModalPresentationStyle:UIModalTransitionStyleFlipHorizontal];
    if (controller) [sender presentModalViewController:controller animated:YES];
    [controller release];

}

The problem is when the composer is displayed the navigation bar is on the top y = 0, but between this bar and the rest of outlets of the view appears an empty space of the same size as the status bar. The status bar is showed in this screen (second issue) but is overlapping the navigation bar of the composer view.

In other projects where the status bar is not hidden, this works like a charm. But this is the first project where it is used without status bar and this is happening.

Anyone knows how to fix it?

Thanks.

NemeSys
  • 555
  • 1
  • 10
  • 28

2 Answers2

3

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];
2

The way I dealt with using iMessage inside an app was to take control of the status bar myself. For example:

[[UIApplication sharedApplication] setStatusBarHidden:FALSE withAnimation:UIStatusBarAnimationSlide];
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:TRUE];
[controller release];

Then when finished either through a send or a cancel:

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
      [self dismissModalViewControllerAnimated:TRUE];
      [[UIApplication sharedApplication] setStatusBarHidden:TRUE withAnimation:UIStatusBarAnimationSlide];
      self.view.frame = CGRectMake(0.0, 0.0, [LayoutHelper width], [LayoutHelper height]);
      self.view.center = CGPointMake([LayoutHelper xCenterPoint], [LayoutHelper yCenterPoint]-20);
}

This seems to display the iMessage and then return to the app without any empty space appearing from the status bar being added or removed.

This is my first post so i hope this helps somehow.

cheers