iOS获取设备信息与应用信息

2016-02-25 0 978
iOS获取设备信息与应用信息

图片来源于网络

iOS获取设备信息

在iOS开发过程中,有时我们想获取到设备的系统信息,这时就需要使用到UIDevice类,具体常用信息获取方式如下:

  • 获取设备唯一标识,同一个开发商的APP获取到的标识是相同的,与UDID不同的是,在我们删除了设备上同一个开发商的所有APP之后,下次获取到的将是不同的标识

    [[UIDevice currentDevice] identifierForVendor];
  • 获取设备系统名称,如iPhone OS

    [[UIDevice currentDevice] systemName];
  • 获取设备系统版本,如7.1

    [[UIDevice currentDevice] systemVersion];
  • 获取设备模式,如iPhone或者iPod touch等

    [[UIDevice currentDevice] model];
  • 获取设备本地模式,返回值与model相同,暂不清楚二者区别

    [[UIDevice currentDevice] localizedModel];
  • 获取设备在\”关于本机\”中的名称,如刘鹏的iPhone 6S

    [[UIDevice currentDevice] name];
  • 获取设备方向,UIDeviceOrientation是一个枚举

    /*
       UIDeviceOrientationUnknown,             // 未知
       UIDeviceOrientationPortrait,            // 竖屏,home键在下方
       UIDeviceOrientationPortraitUpsideDown,  // 竖屏,home键在上方
       UIDeviceOrientationLandscapeLeft,       // 横屏,home键在右方
       UIDeviceOrientationLandscapeRight,      // 横屏,home键在左方
       UIDeviceOrientationFaceUp,              // 平放,屏幕朝上
       UIDeviceOrientationFaceDown             // 平放,屏幕朝下
       */ [[UIDevice currentDevice] orientation];

iOS获取应用信息

在iOS开发过程中,有时我们想获取到应用的信息,这时就需要使用到NSBundle类,具体常用信息获取方式如下:

  • 获取应用名称,如Test

    [[[NSBundle mainBundle] infoDictionary] objectForKey:@\"CFBundleDisplayName\"];
  • 获取应用短版本号,如1.0(用户看到的版本号)

    [[[NSBundle mainBundle] infoDictionary] objectForKey:@\"CFBundleShortVersionString\"];
  • 应用Build版本号,如1.0.8(公司内部使用的版本号,在AppStore修改同一个版本的IPA文件时,可以通过自增Build版本号来实现上传多个)

    [[[NSBundle mainBundle] infoDictionary] objectForKey:@\"CFBundleVersion\"];
  • 获取应用identifier,如com.liupeng.test(常用于需要同一份代码打包成不同应用,通过判断identifier来实现使用不同的第三方key)

    [[[NSBundle mainBundle] infoDictionary] objectForKey:@\"CFBundleIdentifier\"];

转载请注明出处:http://www.jianshu.com/p/d5091396e13c/,请尊重作者劳动成果。

遇见资源网 IOS iOS获取设备信息与应用信息 http://www.ox520.com/23004.html

上一篇: iOS 内存管理
下一篇: iOS绘图
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务