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

编程入门 行业动态 更新时间:2024-10-27 20:35:52
本文介绍了如何仅为iPhone 6和6 Plus限制我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

背景

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

I'm developing a Crossword game app that currently runs on iPad devices. Apple has recently released iPhone 6 and iPhone 6+ devices, which fortunately have a bigger screen and thus become eligibly to run my game (I have tested my game on a iPhone 5S device and if found that it was not pleasant to the user to run in such screen size).

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

In this way, I decided to migrate my app to an Universal binary that would include support for iPhone 6, iPhone 6 Plus and iPad devices.

问题

  • 是有没有办法限制我的iOS应用程序仅在iPhone 6和iPhone 6+设备上运行?
  • 或者,至少:

  • 有没有办法限制我的iOS应用仅在iPhone 6+设备上运行?
  • 推荐答案

    我知道这可能太晚了,无论如何可能都不回答这个问题,但我想'是什么heck' - 确定设备范围是一个很好的代码,在cas中您可能需要不同的功能。

    I know it's probably way too late, and probably doesn't answer the question anyway, but I figured 'what the heck' – it's a nice bit of code to determine ranges of devices, where in cases you may want different functionality.

    #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: stackoverflow/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(5,5c,5s)上识别新的iPhone型号

    注意。由于 containsString ,这将在小于8的iOS版本上崩溃。要支持< 8.0,请尝试使用以下代码重新拟合此函数stackoverflow/a/26416172/1197723

    Note. Due to having containsString, this will crash on iOS versions less than 8. To support <8.0, try using the following code to retro-fit this function stackoverflow/a/26416172/1197723

    玩得开心!

    更多推荐

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

    本文发布于:2023-11-12 03:26:00,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1580372.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:仅为   应用程序   iPhone

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!