我希望我的应用支持 iOS 5.0。但是 Admob 有一个先决条件,即部署目标至少是 6.0。
有没有办法编译我的应用程序,以便 Admob 仅用于运行 iOS >= 6.0 的设备?
我问是因为人们已经对 Apple Watch 做了类似的事情,所以他们可以支持较低的部署目标:iOS7 and Apple Watch
最佳答案
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
然后像这样使用
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
//do admob stuff
}
else {
//don't do admob stuff
}
还链接了在 ios < 6.0 中不可用的可选框架
附言宏取自 this answer
关于ios - 仅当 Deployment target 大于 6.0 时如何使用 AdMob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29940290/