vboombatz
vboombatz

Reputation: 409

How to force one view controller to display in landscape and the other always stay in portrait

I thought this would be simple and I've read a ton on how to do this, but nothing works for me. I'm using xcode 5 and ios7. I have about ten view controllers and I want all of them except one to stay in portrait mode. I want one of the view controllers to only display in landscape left and then when finished the next or previous view controllers will always revert back to portrait only. I cannot figure out how to do this. Any suggestions? I've read a ton of the stuff posted here, but none of it seems to work for me. Thanks

Upvotes: 1

Views: 100

Answers (2)

CW0007007
CW0007007

Reputation: 5681

In the view controller that you don't want to rotate add:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);

}

Upvotes: 1

Jeff Loughlin
Jeff Loughlin

Reputation: 4174

Override supportedInterfaceOrientations in your view controller class. Return

UIInterfaceOrientationPortrait

in the one that should stay in portrait orientation. Return

UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationPortrait

in the one that can rotate.

Upvotes: 1

Related Questions