转换iOS 7的遗留应用程序。大部分问题都已涵盖,但我们有一个功能,使用MFMailComposeViewController通过电子邮件发送错误日志,状态栏在该视图中显示黑色黑色。
状态栏文本颜色使用plist设置全局设置为白色,这似乎可以处理其他所有内容。只有VC正在发送电子邮件。 (我们使用presentModalViewController
呈现它。)
有没有人想出如何破解这个坚果?
更新:尝试继承子类MFMailComposeViewController并实现preferredStatusBarStyle
,但即使在plist中将“基于控制器的状态栏视图”设置为YES,也不会调用它。
答案 0 :(得分: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