Xcode 4.6中的iOS7的statusBar

我想在iOS7中解决statusBar的问题。 我发现这个post ,这个解决scheme在Xcode 5中效果很好。但是当我在Xcode 4.6.3中试过这个代码时,我得到了两个错误:

  1. No visible @interface for 'MyController' declares the selector 'setNeedsStatusBarAppearanceUpdate' ;
  2. Use of undeclared identifier 'UIStatusBarStyleLightContent'

第一个问题是通过使用这个代码解决的: [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; 但我无法解决第二个错误。

这些iOS 7function将不会在XCode 4.6.3中编译,而XCode 4.6.3正在尝试针对iOS 6进行编译。您需要有条件地编译它们。

用以下方式包装有问题的代码:

 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 //iOS 7 only stuff here #endif