Working with the iOS device gyroscope

In this recipe we will learn how to use the features of the Gyroscope events of the iOS device.

Getting ready

We have looked at how to use the iOS devices accelerometer and modify the views background color based on the orientation of the axes. In this recipe we will look at how to incorporate the gyroscope features.

How to do it...

To begin, follow these simple steps as outlined:

  1. Open the AccelGyroExample.xcodeproj project file.
  2. Open the ViewController.m implementation file and modify the viewDidLoad method as shown in the following highlighted code snippet:
    - (void)viewDidLoad { [super viewDidLoad]; // Set up the accelerometer UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer]; accelerometer.updateInterval ...

Get Xcode 4 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.