O'Reilly logo

iPhone JavaScript Cookbook by Arturo Fernandez Montoro

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

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

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