1

为 iOS 7 转换旧版应用程序。解决了大部分问题,但我们有一个功能,可以使用 MFMailComposeViewController 通过电子邮件发送错误日志,并且状态栏在该视图中显示为黑底黑字。

使用 plist 设置将状态栏文本颜色全局设置为白色,这似乎可以很好地处理其他所有内容。只有电子邮件 VC 在起作用。(我们使用 . 来展示它presentModalViewController。)

有没有人想出如何破解这个坚果?

更新:尝试子类化 MFMailComposeViewController 并实现preferredStatusBarStyle,但它没有被调用,即使在 plist 中将“基于视图控制器的状态栏”设置为 YES 之后。

4

1 回答 1

2

以下kluge似乎可以完成这项工作:

        // Present the email controller.  The delegate will dismiss it.
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000
        float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
        if (systemVersion < 7.0f) {
            [viewController presentViewController:emailController animated:YES completion:^{}];
        }
        else {
            // Need a song and dance to get the header bar to show correctly.  (And presentModalViewController is deprecated anyway.)  Note that this code doesn't actually change the email controller's header, but it somehow lets the header below "show through" when it wouldn't otherwise.  (I know -- like many of the iOS 7 fixes this makes no sense.  But it works.  (So far.))
#warning Sometimes produces console message "Presenting view controllers on detached view controllers is discouraged <XxxxViewController: 0xc658a70>"
            [viewController presentViewController:emailController animated:YES completion:^{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
                if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
                    && [[UIApplication sharedApplication] respondsToSelector:NSSelectorFromString(@"setStatusBarStyle:")]) {
                    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
                }
#endif
            }];
        }

#else
        [viewController presentModalViewController:emailController animated:YES];
#endif
于 2014-01-28T20:31:36.977 回答