Pregunta

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?

¿Fue útil?

Solución

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

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

Otros consejos

Try this:

[UIDevice currentDevice].systemVersion
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top