iOS 7 navigation bar under status bar after show mail-sms composer

978 views Asked by At

After upgrade my project to iOS7 my views showed under status bar.Later i fixed this issue by adding following code to DashBoardViewController's(Root navigation controller) viewdidAppear

float systemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
if(systemVersion>=7.0f)
{
    CGRect tmpFrame = self.navigationController.view.frame;
    tmpFrame.origin.y = 20;
    self.navigationController.view.frame = tmpFrame;
}

But in my SettingsViewController when i present modal view to show sms composer, after compose finished or cancelled that view under status bar again. But when back to DashBoardViewController view back to normal. I don't know what to do. I hope I could explain the problem. My codes and screenshots are below.

->ScreenShots: enter image description here

SettingViewController.m ( show SMS compose and finish compose methods)

- (IBAction)act_shareSMS:(id)sender {
    
    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
    NSString* message = @"adasdasd";
    controller.body =message;
    controller.messageComposeDelegate = self;
    
    if([NavigationManager sharedManager].contentNavigation)
        [[NavigationManager sharedManager].contentNavigation presentModalViewController:controller animated:YES];
}

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {

    [[NavigationManager sharedManager].contentNavigation dismissModalViewControllerAnimated:YES];

    if (result == MessageComposeResultCancelled) {
        NSLog(@"Message cancelled");
    } 
    else if (result == MessageComposeResultSent) {
       NSLog(@"Message sent");
    }
}
2

There are 2 answers

2
Fonix On

this change is an intended change to iOS 7, this should help you with dealing with it http://www.doubleencore.com/2013/09/developers-guide-to-the-ios-7-status-bar/

try using the iOS 6/7 delta's on the viewcontrollers subviews to automatically fix this issue

enter image description here

set the delta Y to 20 and it should automatically move it down for you

0
Balram Tiwari On

If you are supporting your app for io7 then I would request you to just read this page and use the concept of "edgesForExtendedLayout". In that way you don't need to put that extra 20px. Just use "edgesForExtendedLayout" under your if.

Just have a look at this example, and you are all set to go. Don't put anything in viewDidAppear, rather move it to viewDidLoad.

Hope this helps.