ios – 如何仅为iPhone 6和6 Plus限制我的应用程序?

CONTEXT

我正在开发目前在iPad设备上运行的填字游戏应用程序.
Apple最近发布了iPhone 6和iPhone 6设备,幸运的是它拥有更大的屏幕,因此可以合法地运行我的游戏(我已经在iPhone 5S设备上测试了我的游戏,如果发现用户运行起来不舒服这样的屏幕尺寸).

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

>有没有办法限制我的iOS应用程序仅在iPhone 6和iPhone 6设备上运行?

或至少:

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

解决方法

我知道这可能为时已晚,并且可能无论如何都没有回答这个问题,但我认为“哎呀” – 这是确定设备范围的一小段代码,在这种情况下你可能需要不同的功能.
#import <sys/sysctl.h>

-(BOOL)isANewerDevice{

    size_t size;
    sysctlbyname("hw.machine",NULL,&size,0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine",machine,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;
}

代码中注释的链接Identify new iPhone model on xcode (5,5c,5s)

注意.由于具有containsstring,这将在小于8的iOS版本上崩溃.要支持< 8.0,请尝试使用以下代码来改进此功能https://stackoverflow.com/a/26416172/1197723

玩得开心!

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...