0
votes

I am really trying to understand how the autorotation works in iOS5 and iOS6 with parent and children View Controller.

Let's say I have a RootViewController with three UIViewControllers The Root View Controller has the three view controllers as Children View Controllers, and is responsible of swapping them UIViewControllers. Now, I want one of the children view controller to be able to autorotate in all interface orientations, and the other two only Portrait Interface Orientation.

Is this possible? How is it done in iOS 5? And iOS 6?

I am really trying to understand all the shouldAutorotateToInterfaceOrientation: supportedInterfaceOrientations preferredInterfaceOrientationForPresentation shouldAutorotate shouldAutomaticallyForwardRotationMethods methods. But I can't get this to work :\ ........

1

1 Answers

0
votes

For those two views (which you want to be available only in portrait mode):

Open their View Controllers, and implement this method:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return UIInterfaceOrientationIsPortrait(toInterfaceOrientation); // don't rotate if it's not portrait. 
// if you don't want the upside down portrait mode to be available as well, return the expression from below
// return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}

This one is actually deprecated, so you also may want to use this:

- (BOOL) shouldAutorotate
{
return YES;
}


-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
    // if you want it to be also in upside down portrait mode, return the expression below
    return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}