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(@"摇一摇");

        }

    }

  • 相关阅读:
    [洛谷P1155] 双栈排序
    [洛谷P4315] 月下”毛景“树
    [洛谷P2486] [SDOI2011]染色
    [HNOI2010] 弾飞绵羊
    mysql注入总结
    cisco交换机实现端口聚合
    python为运维人员打造一个监控脚本
    复习ACCESS注入
    利用sfc文件构建网络渗透
    FTP站点设置
  • 原文地址:https://www.cnblogs.com/bluceZ/p/4629670.html
Copyright © 2011-2022 走看看