传感器--------接近传感器
2016-04-06 12:33
417 查看
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //开启距离传感器检测 [UIDevice currentDevice].proximityMonitoringEnabled = true; //添加<span style="font-family: Arial, Helvetica, sans-serif;">距离传感器距离</span><span style="font-family: Arial, Helvetica, sans-serif;">改变的通知</span> [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityStateDidChange) name:UIDeviceProximityStateDidChangeNotification object:nil]; } - (void)proximityStateDidChange { if ([UIDevice currentDevice].proximityState) { NSLog(@"接近"); //此处写对应功能代码 } else { NSLog(@"远离"); //此处写对应功能代码 } } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- android 传感器(OnSensorChanged)使用介绍
- Android重力传感器实现滚动的弹球
- 为什么三星手机一直坚持使用塑料外壳?
- iOS中传感器的基本使用
- 微软研究院为智能手机研发独特触控技术
- Android的常用传感器开发教程案例
- 利用传感器实现微信的摇一摇功能
- 高压电磁流量计的详细介绍及特点
- 如何才能提高便携式超声波流量计的精度
- VC下读取加速度计
- PSIM可视化智能安防
- PSIM智能可视化指挥管理系统
- JA检索-国际期刊S&T (Sensors and Transducers journal)
- 利用智能手机(Android)追踪一块磁铁(一)
- 利用智能手机(Android)追踪一块磁铁(二)
- andorid系统使用硬件资源_传感器1
- “面子”or“体验” 智能家居如何做设计?
- 什么才是真智能家居?
- 混战!智能家居炙手可热 市场规范有待提升