Forcing Orientation

2 views
Skip to first unread message

Jonathan

unread,
Feb 24, 2009, 2:42:16 PM2/24/09
to phonegap
I just wanted to share something I discovered that others may find
useful. For a few of my apps, I wanted everything to only display in
landscape mode. My preference was to have the home button on the right
as well.

It was pretty easy to do, there are two main changes, you may not need
the first one, but I put it in for good measure.

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);
}



Once you make those changes, when you load the app it will
automatically rotate and stay in that orientation.

Hope that helps.
Reply all
Reply to author
Forward
0 new messages