简体   繁体   English

在iOS7中,MFMailComposeViewController的视图大小已损坏

[英]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. 迁移到iOS 7后,当我显示MFMailComposeViewController并关闭视图控制器时,父视图控制器似乎已上移。 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. 该代码在以前的iOS中效果很好。 Please help me understand what is going on here. 请帮助我了解这里的情况。 This seems to be only on iPhone 这似乎仅在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". 尽管您没有提供有关应用程序的大量详细信息,但是可能发生的原因是iOS7的半透明导航栏和工具栏功能使视图的尺寸“不同”。

To test this, put something like in your viewDidAppear: 要进行测试,请在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). 在iOS7模拟器中运行它,它将返回568,但iOS6将返回455(或类似的设置,取决于您设置视图选项的方式)。

One way to fix the issue, is to go back to the pre-iOS 7 Status Bar. 解决此问题的一种方法是返回iOS 7之前的状态栏。 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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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