zoukankan      html  css  js  c++  java
  • 判断设备总结

    判断设备总结   



    ~~~~~~~~~~~~~~~~~~~~~~~有用取之,无用过之~~~~~~~~~~~~~~~~~~

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    //可通过苹果review
    + (NSString*)getDeviceVersion
    {
        size_t size;
        sysctlbyname("hw.machine", NULL, &size, NULL, 0);
        char *machine = (char*)malloc(size);
        sysctlbyname("hw.machine", machine, &size, NULL, 0);
        NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
        free(machine);
        return platform;
    }


    输出:
    //@"iPad1,1"
    //@"iPad2,1"
    //@"i386"

    逗号后面数字解释:(i386是指模拟器)
    1-WiFi版
    2-GSM/WCDMA 3G版
    3-CDMA版

    AppleTV(2G) (AppleTV2,1)
    iPad (iPad1,1)
    iPad2,1 (iPad2,1)Wifi版
    iPad2,2 (iPad2,2)GSM3G版
    iPad2,3 (iPad2,3)CDMA3G版
    iPhone (iPhone1,1)
    iPhone3G (iPhone1,2)
    iPhone3GS (iPhone2,1)
    iPhone4 (iPhone3,1)
    iPhone4(vz) (iPhone3,3)iPhone4 CDMA版
    iPhone4S (iPhone4,1)
    iPodTouch(1G) (iPod1,1)
    iPodTouch(2G) (iPod2,1)
    iPodTouch(3G) (iPod3,1)
    iPodTouch(4G) (iPod4,1)

    另外放两个固件下载地址:
    http://apple.178.com/ios/
    http://ipad.sj.91.com/ios/

    判断ipad/iphone

    1
    2
    UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
    UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone


    或者

    1
    [[[UIDevice currentDevice] model] isEqualToString:@"iPad"];


    判断设备是否有摄像头

    1
    [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
  • 相关阅读:
    STL--set_difference
    priority_queue和sort应用
    16进制转化8进制---map
    LeetCode62. 不同路径
    LeetCode209. 长度最小的子数组
    LeetCode第29场双周赛题解
    LeetCode61. 旋转链表
    LeetCode60. 第k个排列
    LeetCode59. 螺旋矩阵 II
    LeetCode58. 最后一个单词的长度
  • 原文地址:https://www.cnblogs.com/ligun123/p/2376212.html
Copyright © 2011-2022 走看看