如何检查设备是否是Ipad mini [英] How to check if device is Ipad mini

查看:112
本文介绍了如何检查设备是否是Ipad mini的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

处理iPad Mini屏幕尺寸

是否有可能在运行时检测到你的iOS应用程序在iPad mini上运行?


iPad mini 的分辨率与 iPad 1(2) 1024x768 )。



但是 iPad mini 7,9 英寸,和 iPad 1(2) - 9,7 英寸。



所以问题是如何检查设备是否是Ipad mini。

解决方案

这个答案包含指向实用程序方法的链接,以获取可用于标识各种iOS设备的平台字符串。为方便起见,我在这里复制主要方法:

  #include< sys / types.h> 
#include< sys / sysctl.h>

- (NSString *)平台{
size_t size;
sysctlbyname(hw.machine,NULL,& size,NULL,0);
char * machine = malloc(size);
sysctlbyname(hw.machine,machine,& size,NULL,0);
NSString * platform = [NSString stringWithUTF8String:machine];
免费(机器);
返回平台;
}

根据模型 - iPhone Wiki 平台的返回值是


  • iPad2,5

  • iPad2,6

  • iPad2,7



适用于iPad mini。


Possible Duplicate:
Dealing with iPad Mini screen size
Is it possible to detect that your iOS app is running on an iPad mini at runtime?

iPad mini has the same resolution as iPad 1(2) (1024x768).

But iPad mini has 7,9 inches, and iPad 1(2) - 9,7 inches.

So the question is how to check if device is Ipad mini.

解决方案

This answer contains a link to an utility method to get a "platform string" that can be used to identify the various iOS devices. I copy the main method here for your convenience:

#include <sys/types.h>
#include <sys/sysctl.h>

- (NSString *) platform {
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithUTF8String:machine];
    free(machine);
    return platform;
}

According to Models - The iPhone Wiki, the return value of platform is one of

  • iPad2,5
  • iPad2,6
  • iPad2,7

for an iPad mini.

这篇关于如何检查设备是否是Ipad mini的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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