iOS Motion Detection: Motion Detection Sensitivity Levels

后端 未结 4 1441
我在风中等你
我在风中等你 2021-02-05 18:24

I have a simple question. I\'m trying to detect when a user shakes the iPhone. I have the standard code in place to detect the motion and this works no problem. However, in test

4条回答
  •  太阳男子
    2021-02-05 18:48

    Use core motion. Link your binary with CoreMotion framework. Include #import in your class. Create an instance of CMMotionManager. Set the deviceMotionUpdateInterval property to a suitable value. Then call startDeviceMotionUpdatesToQueue. You will get continuous updates inside the block, which includes acceleration, magnetic field, rotation, etc. You will get the data you require. One thing to be taken care of is that the update shall be so rapid if the interval is too small, and hence you will have to employ suitable logic to handle the same.

提交回复
热议问题