简体   繁体   中英

View Size broken in iOS7 for MFMailComposeViewController

After migrating to iOS 7, when I present MFMailComposeViewController and dismiss the view controller, the parent view controller seems to be moved up. This is how I am presenting view controoler.

MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;        
[mailer setSubject:@"A Message from App"];

[self presentViewController:mailer animated:NO
                     completion:^{
                     }
];

The code worked great in prior iOS. Please help me understand what is going on here. This seems to be only on iPhone

While you didn't present a lot of detailed information about your app, what is likely happening is due to the translucent navigation bar and toolbar feature of iOS7 that makes the dimensions of your views "different".

To test this, put something like in your viewDidAppear:

NSLog(@"height: %f", self.view.bounds.size.height;

Run it in iOS7 simulator and it will return 568, but iOS6 will return 455 (or something similar based on the how you have your view options set).

One way to fix the issue, is to go back to the pre-iOS 7 Status Bar. You could do it in your app delegate:

if(IS_IOS_7) {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    self.window.clipsToBounds =YES;
    self.window.frame =  CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height-20);
    self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM