禁用旧版本iPhone的iPhone应用程序



我有一个iOS应用程序,我只想让它在iPhone 6和6 plus上运行,如何为旧版本的iPhone禁用该应用程序?

您不能阻止用户从应用商店下载它。我建议您使用自动布局,以允许您的对象在所有显示器尺寸上正确显示。

在AppDelegate中获取iOS设备版本并在那里显示消息此设备不支持iOS 7或以前的

这样使用它们:

if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
    // code here
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
    // code here
}

以下过期版本

获取操作系统版本:

[[UIDevice currentDevice] systemVersion]

返回字符串,可以通过将其转换为int/foat

-[NSString floatValue]
-[NSString intValue]

像这个

两个值(floatValue,intValue)都将因其类型而被剥离,5.0.1将变为5.0或5(float或int),为了进行精确比较,您必须将其分离为int数组在这里检查接受的答案:检查iPhone iOS版本

NSString *ver = [[UIDevice currentDevice] systemVersion];
int ver_int = [ver intValue];
float ver_float = [ver floatValue];

并像这个一样进行比较

NSLog(@"System Version is %@",[[UIDevice currentDevice] systemVersion]);
NSString *ver = [[UIDevice currentDevice] systemVersion];
float ver_float = [ver floatValue];
if (ver_float < 5.0) return false;

最新更新