Detecting current orientation

In this recipe, we'll learn how to detect the current orientation of our device. The iPhone includes an accelerometer sensor, which is capable to detect its orientation. For example, if we move the device from its original position to the right, the current orientation will be changed. Despite this recipe being very simple, you can build a complex application based on the detection of the current orientation of the device.

The XHTML file required for this recipe can be located at code/ch09/current_orientation.html in the code bundle provided on the Packtpub site.

Getting ready

This recipe doesn't require any specific framework; however, we're going to use iWebKit for designing a simple layout for a basic user interface. ...

Get iPhone JavaScript Cookbook now with O’Reilly online learning.

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