2014-01-28 128 views
1

轉換iOS的遺留應用程序7.包含大部分問題,但我們有一個功能可以使用MFMailComposeViewController通過電子郵件發送錯誤日誌,並且狀態欄在該視圖中顯示爲黑色。iOS 7 MFMailComposeViewController狀態欄顏色

使用plist設置,狀態欄文本顏色全局設置爲白色,而且似乎處理其他所有事情都很好。只有電子郵件VC正在採取行動。 (我們使用presentModalViewController來呈現。)

有沒有人想過如何破解這個螺母?

更新:試着子類MFMailComposeViewController和實施preferredStatusBarStyle,但它不被調用,即使在plist中的「查看基於控制器的狀態欄中的」設置爲YES後。

回答

2

以下克魯格似乎做的工作:

 // 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