Mina Dawoud
Mina Dawoud

Reputation: 418

Lock the orientation for only the main UIViewController - iOS

I would like to know how I could lock the orientation for my main View Controller but allow my users to rotate to landscape for all the View Controllers?

Thanks in Advance!

Upvotes: 3

Views: 2155

Answers (3)

RKY
RKY

Reputation: 266

This may help you..

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortrait;
}

Upvotes: 0

Kevin
Kevin

Reputation: 17536

- (NSUInteger)supportedInterfaceOrientations {
    UIInterfaceOrientationMaskPortrait
}

The default for iPad is

UIInterfaceOrientationMaskAll

while the iPhone default is

UIInterfaceOrientationMaskAllButUpsideDown

you shouldn't need to implement anything else on your other view controllers

Upvotes: 0

Abdullah Shafique
Abdullah Shafique

Reputation: 6918

For MainViewController:

   -(NSUInteger)supportedInterfaceOrientations
   {
       return UIInterfaceOrientationMaskPortrait;
   }  

Other ViewControllers

   -(NSUInteger)supportedInterfaceOrientations
   {
        return UIInterfaceOrientationMaskLandscape;
   } 

Upvotes: 3

Related Questions