O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

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

Understanding device orientation modes

One of the great benefits for users with current smartphones is the ability to hold the device in any way possible and have the screen rotate to suit its orientation. Titanium allows you to fire event handlers based on orientation changes in your application.

In this recipe, we will create an event handler that fires whenever the orientation on the device is changed, and we will rearrange some UI components on our screen accordingly.

The complete source code for this recipe can be found in the /Chapter 11/Recipe 3 folder.

How to do it…

Open your app.js file, remove any existing code, and type the following:

// // create root window // var win1 = Ti.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); //set ...

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