O'Reilly logo

Xcode 4 iOS Development by Steven F. Daniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exploring the Accelerometer/Gyroscope

So far you have been focusing on how to detect when a user performs taps, swipes, pinches and how to detect device shakes. We now move on to the really exciting stuff, not that what you have already covered is not exciting, but the iPhone's accelerometer is much more powerful than you think and is capable of giving you live data for all three dimensions of the (x, y, and z) axes when the phone is tilted.

The iPhone's accelerometer data is delivered via the UIAccelerometer class and the delegate accelerometer:didAccelerate method which provides you with the data for each of the three axes, each being of UIAcceleration class. Each of the values returned has a range between -1 and +1 with 0 being the middle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required