iOS开发之传感器
来源:互联网 发布:ubuntu mongodb 3.2 编辑:程序博客网 时间:2024/05/18 02:25
iOS开发之传感器
判断当前设备离人或物的距离进行感应
//距离传感器[UIDevice currentDevice].proximityMonitoringEnabled = YES;
直接上代码
//监听距离感应的通知[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityChange:) name:UIDeviceProximityStateDidChangeNotification object:nil];
- (void)proximityChange:(NSNotificationCenter *)notification{ if ([UIDevice currentDevice].proximityState == YES) { NSLog(@"某个物体靠近了设备屏幕"); // 屏幕会自动锁住 } else { NSLog(@"某个物体远离了设备屏幕"); // 屏幕会自动解锁 }}
手机方向
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
- (void)orientationChanged:(NSNotification *)notification{ UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; NSLog(@"当前朝向枚举数字值 %ld",orientation); switch (orientation) { case UIDeviceOrientationPortrait: NSLog(@"portrait ..."); //正立 break; case UIDeviceOrientationPortraitUpsideDown: NSLog(@"portrait UpsideDown ..."); //倒立 break; case UIDeviceOrientationLandscapeLeft: NSLog(@"Landscape Left ..."); //左横屏 break; case UIDeviceOrientationLandscapeRight: NSLog(@"Landscape Right ..."); //右横屏 break; case UIDeviceOrientationFaceUp: NSLog(@"Face Up ..."); //平放 break; case UIDeviceOrientationFaceDown: NSLog(@"Face Down ..."); //反放 break; default: break; }}
0 0
- iOS开发之传感器
- iOS开发之传感器
- iOS开发之传感器
- iOS开发实用技术之传感器
- IOS开发之──传感器使用
- IOS开发之──传感器使用
- IOS开发之——传感器使用
- IOS开发之──传感器使用
- ios开发之距离传感器使用
- IOS开发之──传感器使用
- iOS开发之──传感器使用
- iOS开发--传感器
- iOS开发:距离传感器
- iOS开发 传感器
- IOS开发之──如何使用传感器
- iOS 开发之传感器的使用—<CoreMotion/CoreMotion.h>
- Android开发之传感器
- Windows传感器开发之选择传感器
- rownum用法详解
- struts2中的constant配置详解
- android4.0 USB Camera实例(四)CMOS
- mac os x 添加 用户 所属 组
- 用宏怎么构造标识符
- iOS开发之传感器
- iOS笔记之手势
- 正则表达式(一):纠结的转义
- eclipse编译很慢,可能是js验证浪费时间
- 智能搜索下拉文本框
- ReactiveCocoa – RACSequence介紹
- javax.persistence常用注解配置
- android4.0 USB Camera实例(五)jpg压缩
- 编译安装mmseg提示cannot find input file: src/Makefile.in错误