search

Home  >  Q&A  >  body text

iphone - ios 如何检测摇左边还是右边?

我向左或者右边摇动的时候如何检测到他是要到哪个方向呢?

PHP中文网PHP中文网2773 days ago701

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 12:05:40

    deviceorientation You can get the x, y, z axes of the device running in space
    devicemotion You can get the gravitational acceleration triggered by the device

    The next step is calculation

    You can do a data monitoring to obtain the values ​​​​of the two APIs, and then the tester shakes it repeatedly to find the pattern.

    General idea: acceleration peak + x or y axis peak?

    reply
    0
  • Cancelreply