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

    // ios 4 之前 UIAccelerometer

    // ios 5 <CoreMotion/CoreMotion.h>

    #import "ViewController.h"

    //#import <CoreMotion/CoreMotion.h>

    @interface ViewController ()<UIAccelerometerDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        // UIAccelerometer

        // 1. 创建单利对象

        UIAccelerometer *accelerpmeter = [UIAccelerometer sharedAccelerometer];

        

        // 2. 设置代理

        accelerpmeter.delegate = self;

        

        // 3. 设置采样间隔

        accelerpmeter.updateInterval = 1.0 / 20;

    }

    // 4. 实现代理方法

    #pragma mark - UIAccelerometerDelegate

    /**

     *  只要采集到数据, 就会调用一次(调用频率高)

     *

     *  @param accelerometer 单利对象

     *  @param acceleration  <#acceleration description#>

     */

    //- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration

    //{

    //    LogRed(@"%f --- %f --- %f ----%f",acceleration.timestamp, acceleration.x, acceleration.y, acceleration.z);

    //}

    @end

  • 相关阅读:
    qt动态加载UI文件
    Qt常见控件和操作
    MySQL
    tomcat
    linux iptables基础
    linux 网络基础
    linux CA及OpenSSL学习
    k8s 访问控制
    k8s 存储卷
    docker 安装部署
  • 原文地址:https://www.cnblogs.com/guangleijia/p/4833216.html
Copyright © 2011-2022 走看看