<分区>
我有一段代码只能在 iOS 6 或更高版本上运行。
control.tintColor = [UIColor greenColor];
是否有像 #ifdef iOS6_or_greater
这样随时可用的编译器指令?
标签 ios objective-c
<分区>
我有一段代码只能在 iOS 6 或更高版本上运行。
control.tintColor = [UIColor greenColor];
是否有像 #ifdef iOS6_or_greater
这样随时可用的编译器指令?
最佳答案
最好检查功能,而不是 iOS 版本。
例如,您可以使用 respondsToSelector 查看是否支持给定的方法。
[someObject respondsToSelector:@selector(someMethod)]
否则,有一个预处理器指令
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
- (BOOL)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
#endif
关于ios - 仅当高于特定 iOS 版本时如何有条件地包含代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18572070/