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

  • 相关阅读:
    如何把一个一般的git库变成“裸库”?
    MacOSX下杀掉sudo进程
    nginx FastCGI错误Primary script unknown解决办法
    Lua继承userdata
    Unity图文混排
    C++轻量级跨平台文件系统API
    lua_next()
    重载方法匹配算法
    C++模板函数只能全特化不能偏特化
    xcode离线安装包下载
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/6921223.html
Copyright © 2011-2022 走看看