Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default app orientation

I have an app written in an older version of Xcode. Right now I'm using Xcode 4.6.1. This is an app I inherited from another developer that was developed outside the company.

One of the problems with this app is its interface. It should default to LandscapeLeft (this is the value set in the pList file). The app ignores this directive and instead defaults to portrait mode.

Is there something I need to do to force the code to honor this value? I'm relatively new to iOS/Objective-C. The code compiles and runs, it's just the interface isn't doing what I want.

It's a little easier since this is an iPad only app.

Edit I've tried adding the following code to one of my problematic viewControllers, but it's not being honored. Any thoughts on how to force this view to landscape? (Is there a setting in the IDE - it looks like Xcode used to have an orientation attribute, but I can't find it in 4.6.1)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return ((interfaceOrientation==UIInterfaceOrientationMaskLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationMaskLandscapeRight));
}

- (NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (NSInteger) supportedInterfaceOrientationsForWindow
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL) shouldAutoRotate
{
    return YES;
}
like image 488
Tim Avatar asked Dec 20 '22 07:12

Tim


2 Answers

I hope this will help you. Add one of this(which orientation you want) method in AppDelegate.m class

For force fully run application in landscape mode:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskLandscape;
}

For force fully run application in Portrait mode:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}
like image 173
Ashvin A Avatar answered Dec 24 '22 09:12

Ashvin A


Check whether view controllers in the app force view orientation. Check section 'Handling View Rotations' and tasks related to rotation in Apple's documentation:

http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html

like image 24
gberginc Avatar answered Dec 24 '22 10:12

gberginc