phonegap

 

Forcing a Landscape Orientation

Page history last edited by Jon 8 mos ago

If you'd like your app to be stuck in Landscape Orientation (Home button on the right), this tutorial is for you. After you have made the small changes below, when your application loads it will stay in landscape mode regardless of how you hold the phone.

1. open GlassAppDelegates.m

 

 

2. scroll down until you find:

     - (void)applicationDidFinishLaunching: (UIApplication *)application {

 

 

3. add this as the first line in the above section: 

        application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;

 

 

4. Open GlassViewController.m

 

5. add this right before the last line, which is @end:

 

 

     -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { 

             if(interfaceOrientation == UIInterfaceOrientationPortrait) 

                     return NO; 

             if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) 

                    return YES;

             return (interfaceOrientation == UIInterfaceOrientationPortrait);

 

     }

Comments (2)

profile picture

Kemal Seref said

at 11:59 pm on Apr 12, 2009

great! force portrait orientation by changing YES & No in 5.

You don't have permission to comment on this page.