O'Reilly logo

iPhone Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

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

8. The Accelerometer

One of the flashiest features of the iPhone is the accelerometer. The accelerometer detects the device’s real-world orientation by tracking the force of the earth’s gravity on its X, Y, and Z axes. You can also use the accelerometer data to detect changes in the device’s velocity.

In this chapter, you are going to use the accelerometer to skew the center of the HypnosisView according to orientation: when the user tilts the phone, the center will slide in the direction of the tilt, as shown in (Figure 8.1).

Figure 8.1. HypnosisView

image

Setting Up the Accelerometer

To receive accelerometer data, your application needs to give ...

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