views:

330

answers:

1

My App has a UITabBarController with five tabs. I needed to rotate orientations only for the fifth tab. I was able to get all five to rotate to landscape by subclassing the UITabBarController

@implementation TabBarControllerRotate

  • (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {

    //return (interfaceOrientation == UIInterfaceOrientationPortrait); return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationPortrait); }

@end

if(tbc == nil){ //tbc = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; tbc = [[TabBarControllerRotate alloc] initWithNibName:nil bundle:nil]; ////// new ////// ....

tbc.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3 ,viewController4,viewController5, nil];


I need now to turn off the rotation for viewController1 - 4 ; I tried unsuccessfully to do this by adding the following code to the four *.m files for these viewControllers.

  • (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {

    return NO; }

Please advise me on how to Get R Done. Thanks for reading, Mark

A: 
mbarron