Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setNeedsStatusBarAppearanceUpdate unrecognized selector

Tags:

ios

cordova

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.

like image 563
inorganik Avatar asked Feb 15 '23 23:02

inorganik


1 Answers

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];
}
like image 82
Ben Baron Avatar answered Feb 23 '23 01:02

Ben Baron