在我的 AppDelegate 中,我使用外观代理制作自定义 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];
这会在 iOS4 中崩溃。如何检查此功能在他们运行的 iOS 版本上是否可用,从而避免崩溃?
最佳答案
不检查操作系统,检查功能是否存在。
if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {}
关于iphone - 如何检查某个功能是否适用于特定的 iOS 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8015192/