Kuldeep Bhimte
Kuldeep Bhimte

Reputation: 959

How to set two of the screens in Portrait mode and another two screen in Landscape on iPhone?

I have a homeViewController (should always be in portrait mode) , which has four buttons to be redirected to a tar bar controller, which has four different viewController (first, second, third, fourth).

We want to have firstViewController and fourthViewController in portrait mode always. And secondViewController and thirdViewController in landscape mode always, also when we will go back to homeViewController form any of these viewControllers the homeViewController should always be in portrait mode.

Upvotes: 0

Views: 107

Answers (1)

katzenhut
katzenhut

Reputation: 1742

You can use the -shouldAutrotate - Method of the ViewControllers to make sure they dont rotate when the device does. Just return NO, and the VC will always be displayed like your xib-file or storyboard specifies. Heres the docs: https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW124

and heres an example:

-(BOOL)shouldAutorotate{
    return NO;
}

EDIT: In Response to your coment:

UITabBarControllers wont forward the shouldAutorotate - Value to the ChildViewControllers. (As a sidenote, neither will a NavigationController). Your best bet is to subclass The TabBarController. Heres a link to a Stackoverflow-Post describing this. Have fun. IO6 doesn't call -(BOOL)shouldAutorotate

Upvotes: 1

Related Questions