zoukankan      html  css  js  c++  java
  • 传感器

    // 距离传感器

    // 温度传感器

    // 磁力传感器

    // 光传感器

    // 湿度传感器

    // 陀螺仪  -- 导航, 赛车游戏(角速度传感器)

    // 运动传感器 - 加速度传感器  --  摇一摇, 计步器

    //

    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        // 距离传感器 - 默认是关闭的

        // 1. 开启距离传感器 - 开启之后就会实时监听

        [UIDevice currentDevice].proximityMonitoringEnabled = YES;

        

        // 2. 当监听到有物体靠近设备时, 会调用通知

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ProximityStateDidChanged:) name:UIDeviceProximityStateDidChangeNotification object:nil];

        

    }

    - (void)ProximityStateDidChanged:(NSNotification *)noticefication

    {

        LogRed(@"%@",noticefication);

        if ([UIDevice currentDevice].proximityState){

            LogGreen(@"靠近-----靠近");

        }else{

            LogMagenta(@"离开 ---  离开");

        }

        

    }

    - (void)dealloc

    {

        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceProximityStateDidChangeNotification object:nil];

    }

    @end

  • 相关阅读:
    跨浏览器的事件处理程序
    jQuery提交Form
    js 多种变量定义(对象直接量,数组直接量和函数直接量)
    Asp.net Eval 截取字符串
    sql执行顺序
    IDEA File Templates模板
    Vim快捷键大全(转)
    Rider+Unity+XLua环境配置
    一定要进行代码复查
    如何在ubuntu上面安装luasocket
  • 原文地址:https://www.cnblogs.com/guangleijia/p/4833095.html
Copyright © 2011-2022 走看看