4

I had an issue with my iOS phonegap app having the status bar overlap the webview in iOS 7. I found this answer which fixed the problem, but the second step, calling

[self setNeedsStatusBarAppearanceUpdate];

in viewDidLoad causes the app to crash in iOS 6 and throw unrecognized selector.

Community
  • 1
  • 1
inorganik
  • 24,255
  • 17
  • 90
  • 114

2 Answers2

8

In the future, if you ever need to use something from iOS 7, such as setNeedsStatusBarAppearanceUpdate and you need to still support earlier iOS versions, you can first check if the selector is supported:

if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
{
    [self setNeedsStatusBarAppearanceUpdate];
}
Ben Baron
  • 14,496
  • 12
  • 55
  • 65
  • I tried that initially, but was getting an "undefined selector" error, and it would crash. Now it seems to work just fine on the simulator and on an iPhone running iOS 6. Go figure... – inorganik Oct 28 '13 at 17:43
0

Turns out it is unnecessary to add [self setNeedsStatusBarAppearanceUpdate]; and the app ran fine in iOS 6 and iOS 7.

inorganik
  • 24,255
  • 17
  • 90
  • 114