Bilal hussain
Bilal hussain

Reputation: 105

Set only one ViewController in landscape mode

I am new in ios.

I want to show only one viewController in landscape mode other all in portrait.

So please help me and tell me how can I change only one view in landscape mode in app.

I have already searched for it but have not found any particular answer.

Upvotes: 4

Views: 3354

Answers (3)

Mindaugas
Mindaugas

Reputation: 1735

For iOS6, add this method to your ViewController

-(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationMaskLandscape;
}

Upvotes: 2

Abid Hussain
Abid Hussain

Reputation: 1549

if you are using navigation controller and controller which is pushing this 'Landscape-oriented' view controller is in only portrait mode then you'll have to manually rotate the uiview by CGAffineTransformation.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // If you require full screen then hide the navigation bar with following commented line.
    //[self.navigationController setNavigationBarHidden:YES animated:NO];

    // Rotates the view.

    CGAffineTransform transform = CGAffineTransformMakeRotation(-M_PI/2);
    self.view.transform = transform;

    // Repositions and resizes the view.
    // If you need NavigationBar on top then set height appropriately 
    CGRect contentRect = CGRectMake(0, 0, 480, 320);
    self.view.bounds = contentRect;
}

Upvotes: 4

Mark McCorkle
Mark McCorkle

Reputation: 9414

Are you using a UINavigationController?

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

-(BOOL) shouldAutorotate {
    return YES;
}

Upvotes: 0

Related Questions