Chapter 17. Positioning: accelerometers and location
This chapter covers
- Measuring gravity
- Gauging movement
- Determining location
When we first introduced the iPhone, we highlighted a number of its unique features. Among them were two components that allow the iPhone to figure out precisely where it is in space: a trio of accelerometers, which give it the ability to sense motion in three dimensions, and a locational device (using either GPS or faux GPS), which lets it figure out where in the world it is.
Other than accessing some basic orientation information, we haven’t done much with these features. That’s because most of the functionality isn’t available to the web interface, and because it lies beyond the basic concepts of the SDK that we’ve covered so far. But now we’ll dive into these positioning technologies and examine how to use them in your programming.
We’re going to start off with some new ways to look at orientation data, and then we’ll expand into some original possibilities.
The easiest use of the accelerometers is to determine the iPhone’s current orientation. We already used the view controller’s interfaceOrientation property, back in chapter 13. As we mentioned at the time, though, you can also access orientation information through the UIDevice object. It can provide more information and realtime access that isn’t available using the view controller.