Question

In my AppDelegate I am using the appearance proxy to make custom UI:

//Setup custom appearances
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
    [[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];

This will crash in iOS4. How can I check if this feature is available on the iOS version they are running, so I can avoid the crash?

Était-ce utile?

La solution

Don't check the OS, check if the capability exists.

if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {}

Autres conseils

Try this:

[UIDevice currentDevice].systemVersion
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top