Search code examples
iphoneioscore-motion

Tilt location iOS app


How can I determine the tilt location in the y direction on my iOS app? First I tried playing with the accelerometer. But the accelerometer values change even if the iPhone isn't tilting. Then I tried playing around with the gyroscope. But that only senses the rate of the tilt, not the position of the tilt.

Here is specifically what I am trying to do:

If you place an iPhone on a table in landscape position with the home button on the top. Then you slowly proceed to flip it in a manner such that the display is now facing down (you see the back of the phone) and the home button is still on the left. That tilt motion that is needed to do that is what I'm trying to measure.


Solution

  • You should consider to use the Core Motion API because it provides the values ready to use as Euler angle, quaternion or rotation rate. Have a look at

    Accelerometer detection and sprite rotation

    iPhone - What does the gyroscope measures? Can I get an absolute degree measurement in all axis?

    iphone - core motion (relative rotation)