- (void)viewDidLoad

{

    [super viewDidLoad];

    // 操作系统

    NSString * osName  =[[UIDevice currentDevice]systemName];

    // 操作系统版本

    NSString * systemVersion  =[[UIDevice currentDevice]systemVersion];

    NSLog(@"os =%@ ",osName);

    NSLog(@"version =%@",systemVersion);

    // IOS设备模型

    NSString *iosmodel  =[[UIDevice currentDevice]model];

    NSLog(@"%@",iosmodel);

    //  电量的范围从0.0(全部泻出)-1.0(100%)在访问这个属性之前要确保batterymonitoring这个属性是可用的

    // 电量查询

    float batteryLevel =  [UIDevice currentDevice].batteryLevel;

    NSLog(@"%f",batteryLevel);

    // 检测电池状态

    UIDeviceBatteryState batteryState = [[UIDevice currentDevice]batteryState];

    //    有如下几个状态

    //  UIDeviceBatteryStateUnknown 0  未识别         0

    //  UIDeviceBatteryStateUnplugged, 充电中         1

    //  UIDeviceBatteryStateCharging,  少于100%       2

    //  UIDeviceBatteryStateFull,      充满了         3

    NSLog(@"%d",batteryState);

    // 检测是否支持多任务处理

    BOOL support =[[UIDevice currentDevice]isMultitaskingSupported];

    if(support)

    {

        NSLog(@"supportmultiTask");

    }

    else

    {

        NSLog(@"don,t supportmultiTask");

    }

     // 检测当前设备方向是否改变

     // YES 方向改变

     // NO  方向未改变

     BOOL status =[UIDevice currentDevice].generatesDeviceOrientationNotifications ;

     NSLog(@"%d",status);

     // 开始改变设备方向 如果需要在改变方向的时候处理一些事情可以重写这个方法

     // [[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications ];

     // 结束改变设备方向 同上

     // [[UIDevice currentDevice]endGeneratingDeviceOrientationNotifications];

     // 临近状态检测

     // 当你的身体靠近iPhone而不是触摸的时候,iPhone将会做出反应。(需要一定的面的影射,约5mm左右的时候就会触发)

     // YES 临近  消息触发

     // NO

    BOOL proximityState = [[UIDevice currentDevice]proximityState];

    NSLog(@"%d",proximityState);

    UIDevice *device =  [UIDevice currentDevice ];

    device.proximityMonitoringEnabled=YES; // 允许临近检测

    // 临近消息触发

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(proximityChanged:)

                                                name:UIDeviceProximityStateDidChangeNotification object:device];

}

 // 临近手机消息触发

- (void) proximityChanged:(NSNotification *)notification {

    UIDevice *device = [notification object];

    NSLog(@"In proximity:%i",device.proximityState);

    if(device.proximityState==){

        //do something

    }

}

IOS设备 UIDevice 获取操作系统 版本 电量 临近手机触发消息检测 (真机亲测可用)的更多相关文章

  1. iOS设置竖屏,播放视频可以任性旋转的解决方法,亲测可用

    之前在网上找了很多方法,都是强制横屏,但是如果设备关闭旋转锁定,强制横屏后把设备竖立起来,播放器也会跟着竖过来,但是就回不去了.现在项目要求让app默认都是竖屏,只有在全屏播放的时候可以自由旋转,于是 ...

  2. Js获取操作系统版本 && 获得浏览器版本

    //利用原生Js获取操作系统版本function getOS() { var sUserAgent = navigator.userAgent; var isWin = (navigator.plat ...

  3. Axure RP 9版本最新版授权码和密钥 亲测可用

    分享Axure RP 9版本最新版授权码和密钥 亲测可用 声明:以下资源的获取来源为网络收集,仅供学习参考,不作商业用途,如有侵权请联系博主删除,谢谢! 自新的Axure RP 9.0 Beta版发布 ...

  4. JProfiler 9版本注册码(亲测可用!!!)

    JProfiler 9版本注册码(亲测可用!!!) 按默认选择“Single or evaluation license” ,Name 和 Company 随意填!!! JProfiler 9.2  ...

  5. Eclipse4.5 Mars版本安装activiti插件 亲测可用

    Eclipse4.5 Mars版本安装activiti插件 亲测可用 学习使用activiti 在线安装一直,国内的网络真心的是 很苦 啊:在茫茫网络上面找到了很多插件的离线包 终于找到一个可以使用的 ...

  6. XE7 & IOS开发之开发账号(1):开发证书、AppID、设备、开发授权profile的申请使用,附Debug真机调试演示(XCode所有版本通用,有图有真相)

    网上能找到的关于Delphi XE系列的移动开发的相关文章甚少,本文尽量以详细的图文内容.傻瓜式的表达来告诉你想要的答案. 原创作品,请尊重作者劳动成果,转载请注明出处!!! 注意,以下讨论都是以&q ...

  7. NTDLL未文档化函数RtlGetNtVersionNumbers获取操作系统版本

    作为新手,对获取操作系统版本号好奇过,因为曾经假象过一个场景:自己的程序在windows xp环境下编译,在windows 2003, windows 7,windows 8是否需要提权或者兼容处理, ...

  8. windows和linux下如何远程获取操作系统版本和主机名

    远程获取windows和linux操作系统版本和主机名需要具备以下条件: 假设 主机A(windows 7),ip:192.168.12.2 主机B(centos 6.3),ip:192.168.12 ...

  9. WindowsAPI使用详解——GetVersion|GetVersionEx 获取操作系统版本和名称

      Windows API 中有两个函数可以得到系统版本信息:GetVersion和GetVersionEx.      GetVersion这个函数曾经困扰了很多程序员,其本来设计的是在DWORD返 ...

随机推荐

  1. MergeRecord_C++中map的使用

    //============================================================================ // Name : TTTest.cpp ...

  2. ADO.NET学习

    ADO.NET重要的类 在.NET访问MySql数据库时的几点经验! string connstr=Setting.Instance().GetConnectionString("MySql ...

  3. spark发行版笔记13

    本期概览: ReceiverTracker架构设计 消息循环系统 ReceiverTracker具体的实现 Spark Streaming作为Spark Core基础 架构之上的一个应用程序,其中的R ...

  4. 小游戏Step表

    [Config]1|0|0|2|172,120,134|公主的记忆|1|2[Config] [Config]2|1|1|2|172,120,134|公主的记忆|1|2[Config] [Config] ...

  5. 关于arcengine中geoprocessor使用的困惑

    最近在实验一个小功能,就是用arcengine10.1做一个小程序,将point类型的shp转换为polyline类型的shp文件,用到的工具是pointstoline,但就是在设置input_fea ...

  6. 在APACHE服务器上的访问方式上去除index.php

      在APACHE服务器上的访问方式上去除index.php   下面我说下 apache 下 ,如何 去掉URL 里面的 index.php 例如: 你原来的路径是: localhost/index ...

  7. hdoj 5074

    Problem Description Hatsune Miku is a popular virtual singer. It is very popular in both Japan and C ...

  8. ubtuntu 下安装Erlang R17

    在Ubuntu 下 Erlang R17B 的安装的过程记录: 1 :如果你主机上没有安装jdk,那需先安装,安装过程如下:   #   sudo apt-get update (更新已安装的包)   ...

  9. Erlang&RabbitMQ服务安装配置

    RabbitMQ是流行的开源消息队列系统,是AMQP(Advanced Message Queuing Protocol高级消息队列协议)的标准实现,用erlang语言开发.RabbitMQ据说具有良 ...

  10. JQuery 判断不同浏览器

    if($.browser.msie) {          //IE浏览器alert("this is msie"); } else if($.browser.safari)   ...