zoukankan      html  css  js  c++  java
  • 加速计

    // 1.创建加速计对象

        UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer];

        // 2.设置代理

        accelerometer.delegate = self;

        // 3.设置采样时间

        accelerometer.updateInterval = 1.0/60;

        //实现代理方法

    #pragma mark - UIAccelerometerDelegate

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

    {

    NSLog(@"x = %.1f, y = %.1f z = %.1f", acceleration.x , acceleration.y , acceleration.z);

        // 获取加速度

        /*

         Vt = V0 + a * t (最终速度 = 初始速度 + 加速度 * 时间)

         Vt = V0 + g * t (加速度是恒定的9.8)

         Vt = V0 + g1 + g2 + g3 … (时间和加速度都是恒定的)

         Vt = V0 + a1 + a2 + a3 … (手机中时间是恒定的, 加速度不是恒定的)

         */

    }

    3、手机摇动事件

    - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

    {

        // 判断摇晃事件类型

        if (motion == UIEventSubtypeMotionShake) {

            NSLog(@"摇一摇");

        }

    }

  • 相关阅读:
    1619: 【例 1】Prime Distance
    Apache的架构师们遵循的30条设计原则(转帖)
    DP秒思维
    dsu on tree入门
    莫队入门
    行列式与霍尔基夫矩阵
    高精度板子
    splay入门
    回文自动机入门
    AC自动机
  • 原文地址:https://www.cnblogs.com/bluceZ/p/4629670.html
Copyright © 2011-2022 走看看