zoukankan      html  css  js  c++  java
  • [iOS]iOS获取设备信息经常用法

    郝萌主倾心贡献。尊重作者的劳动成果。请勿转载。

    假设文章对您有所帮助。欢迎给作者捐赠。支持郝萌主。捐赠数额任意,重在心意^_^ 

    我要捐赠: 点击捐赠

    Cocos2d-X源代码下载:点我传送

    游戏官方下载:http://dwz.cn/RwTjl

    游戏视频预览:http://dwz.cn/RzHHd

    游戏开发博客:http://dwz.cn/RzJzI

    游戏源代码传送http://dwz.cn/Nret1


    1. 经常用法

    NSLog(@"HostName: %@", [[NSProcessInfo processInfo] hostName]);
    //globallyUniqueString 唯一的标示符,每次调用都会不一样,能够用作一些暂时缓存文件的名字
    NSLog(@"GlobalUniqueString: %@", [[NSProcessInfo processInfo] globallyUniqueString]);
    //操作系统名称
    NSLog(@"OperatingSystemName: %@", [[NSProcessInfo processInfo] operatingSystemName]);
    //操作系统版本号
    NSLog(@"OperatingSystemVersion: %@", [[NSProcessInfo processInfo] operatingSystemVersionString]);
    //物理内存
    NSLog(@"PhysicalMem: %llu", [[NSProcessInfo processInfo] physicalMemory]);
    //进程名称
    NSLog(@"ProcessName: %@", [[NSProcessInfo processInfo] processName]);
    //供应商标识
    NSLog(@"UniqueId: %@", [UIDevice currentDevice].identifierForVendor);
    //设备类型(iPhone、iPad)
    NSLog(@"userInterfaceIdiom: %d", [UIDevice currentDevice].userInterfaceIdiom);
    //设备名字
    NSLog(@"Name: %@", [UIDevice currentDevice].name);
    //系统名字
    NSLog(@"SystemName: %@", [UIDevice currentDevice].systemName);
    //系统版本号
    NSLog(@"SystemVersion: %@", [UIDevice currentDevice].systemVersion);
    //模型
    NSLog(@"Model: %@", [UIDevice currentDevice].model);
    //本地化的模型
    NSLog(@"LocalizeModel: %@", [UIDevice currentDevice].localizedModel);
    //电池状态
    NSLog(@"BatteryLevel: %f", [UIDevice currentDevice].batteryLevel);
    

    2. 推断设备是否是9.0以上系统
    [[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0f
    注意:
    假如我们的设备版本号号为9.1.1(为字符串类型),对其进行floatValue浮点化后值为9.100000。


    3. 推断设备是否是iPhone、iPad
    iPad:[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
    iPhone: [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
    
    UIUserInterfaceIdiom in UIDevice.h
    typedef NS_ENUM(NSInteger, UIUserInterfaceIdiom) {
    #if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
        UIUserInterfaceIdiomPhone,           // iPhone and iPod touch style UI
        UIUserInterfaceIdiomPad,             // iPad style UI
    #endif
    };

    郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。

    假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额任意。重在心意^_^ 

    我要捐赠: 点击捐赠

    Cocos2d-X源代码下载:点我传送

    游戏官方下载:http://dwz.cn/RwTjl

    游戏视频预览:http://dwz.cn/RzHHd

    游戏开发博客:http://dwz.cn/RzJzI

    游戏源代码传送http://dwz.cn/Nret1

  • 相关阅读:
    springcloud配置中心
    burnside+polya 整理
    线段树-小总结
    D. Artsem and Saunders
    444 D. Ratings and Reality Shows
    P1337 [JSOI2004]平衡点 / 吊打XXX
    Typora + Open Live Writer 管理博客园
    旋转卡壳
    B. Alyona and a tree
    set的用法
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/6921223.html
Copyright © 2011-2022 走看看