如何限制我的应用程序只有iPhone 6和6 Plus?

CONTEXT

我正在开发当前在iPad设备上运行的填字游戏应用程序。 苹果公司最近发布了iPhone 6和iPhone 6+设备,幸运的是屏幕更大,因此成为合格的游戏运营商(我已经在iPhone 5S设备上testing了游戏,如果发现用户运行起来并不愉快在这种屏幕尺寸)。

这样,我决定将我的应用程序迁移到通用二进制文件,其中包括对iPhone 6,iPhone 6 Plus和iPad设备的支持。

  1. 有没有办法限制我的iOS应用程序只能在iPhone 6和iPhone 6 +设备上运行?

或者至less:

  1. 有没有办法限制我的iOS应用程序只能在iPhone 6+设备上运行?

我知道这可能太晚了,可能也没有回答这个问题,但是我想到了“这到底是什么东西” – 确定设备的范围是一个很好的代码,在这种情况下你可能需要不同的function。

#import <sys/sysctl.h> -(BOOL)isANewerDevice{ size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = malloc(size); sysctlbyname("hw.machine", machine, &size, NULL, 0); NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; free(machine); NSString * ending = [platform substringFromIndex:[platform length]-3]; double convertedNumber = [[ending stringByReplacingOccurrencesOfString:@"," withString:@"."] doubleValue]; //Devices listed here: https://stackoverflow.com/questions/19584208/identify-new-iphone-model-on-xcode-5-5c-5s if ([platform containsString:@"iPhone"]) { if (convertedNumber >= 7.1) { // 6 and above return YES; }else{ return NO; //less than a 6 (ie 5S and below) } }else if ([platform containsString:@"iPad"]){ if (convertedNumber >= 5.3) { //iPad Air 2 and above return YES; }else{ return NO; //iPad Mini 3 and below } } //Failsafe return NO; } 

在代码中评论的链接: 在xcode上标识新的iPhone模型(5,5c,5s)

注意 。 由于拥有containsString ,这将在iOS版本less于8时崩溃。为了支持<8.0,请尝试使用以下代码来改写此函数https://stackoverflow.com/a/26416172/1197723

玩的开心!