O'Reilly logo

Xcode 4 Cookbook 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

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 ...

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