iPad mini和iPad Air之间有何区别? [英] How to differ between ipad mini and ipad air?

查看:76
本文介绍了iPad mini和iPad Air之间有何区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在模拟器iPad mini(我使用的是iPad 2配置文件)和iPad Air上运行时,它显示的分辨率相同,为1024x768

When I run on simulator ipad mini (which I am using ipad 2 profile) and ipad air it shows the same resolution 1024x768

对于UI Kit,它可能会自动调整,但是我使用的是cocos2d

for UI Kit it might adjust automatically but I using cocos2d

推荐答案

Apple确实不希望您能够检测到此问题,因此他们没有提供一种简便的方法来检测它.我认为您应该真正问自己为什么要知道.

Apple don't really want you to be able to detect this, so they've not provided an easy way to do it. I think you should really ask yourself why you need to know.

也就是说,我碰巧有一个统治者应用程序",这可能是极少数有区别地对待mini的合法理由之一.我把它放在UIDevice的一个类别中

That said, I happen to have a 'ruler app', which is probably one of the very few legitimate reasons to treat the mini differently. I put this in a category on UIDevice

界面:

//  UIDevice+JEFkit.h

typedef NS_ENUM (NSUInteger, deviceClass) {

deviceClass_iPhone = 0,    
deviceClass_iPhoneTall = 1,    
deviceClass_iPhoneSix = 2,     
deviceClass_iPhoneSixPlus= 3,

 deviceClass_iPadMini = 10,
 deviceClass_iPad = 11,

deviceClass_unknown

};

@interface UIDevice (JEFkit)

#pragma mark device type..

+(deviceClass )deviceClass;
//some other stuff..
@end

实现:

+(deviceClass )deviceClass{

  NSUInteger greater = ((NSUInteger )fmaxf([[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height));

  switch (greater) {
    case 480:
      return deviceClass_iPhone;
      break;
    case 568:
      return deviceClass_iPhoneTall;
      break;
    case 667:
      return deviceClass_iPhoneSix;
      break;
    case 736:
      return deviceClass_iPhoneSixPlus;
      break;
    case 1024:
      // its an ipad, what size ?
    {

      size_t size1;
      sysctlbyname("hw.machine", NULL, &size1, NULL, 0);
      char *machine1 = malloc(size1 + 1);
      sysctlbyname("hw.machine", machine1, &size1, NULL, 0);
      machine1[size1] = 0;

      if (strcmp(machine1, "iPad1,1") == 0 || strcmp(machine1, "iPad2,1") == 0 || strcmp(machine1, "iPad2,2") == 0 || strcmp(machine1, "iPad2,3") == 0 || strcmp(machine1, "iPad2,4") == 0 ) {

        /* iPad 1 or 2 */
        free(machine1);
        return deviceClass_iPad;
      }

      if ([[UIScreen mainScreen]respondsToSelector:@selector(scale)]) {
        if ([[UIScreen mainScreen] scale] < 2.0) {
          free(machine1);


          return deviceClass_iPadMini; //all other non-retina full sized iPad devices are eliminated, must be first GEN mini

          /// nb the iPad simulator also in here..

        }
      }else{
        ///does not respond to @selector(scale)
        /// should not ever happen

        free(machine1);
        return deviceClass_iPad;
      }

      //ok only retina ipads are left...
      if (strcmp(machine1, "iPad4,4") == 0 || strcmp(machine1, "iPad4,5") == 0 || strcmp(machine1, "iPad4,6") == 0 || strcmp(machine1, "iPad4,7") == 0 || strcmp(machine1, "iPad4,8") == 0 || strcmp(machine1, "iPad4,9") == 0) {
        /* 2nd/3rd gen minis w retina*/


        ////TODO////

        /// future retina minis !!! ///

        free(machine1);
        return deviceClass_iPadMini;
      }

      //known retina minis are eliminated..

      free(machine1);
      return deviceClass_iPad;
    }
      break;
    default:
      break;
  }

  return deviceClass_unknown;
}

这篇关于iPad mini和iPad Air之间有何区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆