1

I have SubClass of UITabBarController for handle the rotation issue:

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

-(NSUInteger)supportedInterfaceOrientations{
    return [self.selectedViewController supportedInterfaceOrientations];
}

-(BOOL)shouldAutorotate{
    return YES;
}

And Now from one of the UIViewController in the tabbatcontroller i present a new UIViewController:

MainVC *mainVC = [[MainVC alloc] initWithNibName:@"MainVC" bundle:nil];
UINavigationController *mainNav = [[UINavigationController alloc] initWithRootViewController:mainVC];

radioNav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:mainNav animated:YES];

And in this new Navigation i want to disable auto rotate and allow only portrait :

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

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate{
    return NO;
}

But the rotation still working and when i rotate the screen the app go to landscape screen, how i can fix this issue?

Shardul
  • 4,266
  • 3
  • 32
  • 50
YosiFZ
  • 7,792
  • 21
  • 114
  • 221
  • You need to check every time current device Orientation or device status-bar Origination :- Please Check my answer on this:- http://stackoverflow.com/questions/16710899/force-portrait-in-one-view-controller-makes-other-to-be-in-portrait-initially/16711127#16711127 – Nitin Gohel May 27 '13 at 12:55

1 Answers1

1

You should also subclass UINavigationController and put the following code in your subclass:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // You do not need this method if you are not supporting earlier iOS Versions
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate
{
    return NO;
}

Then, init an instance of your subclass:

MainVC *mainVC = [[MainVC alloc] initWithNibName:@"MainVC" bundle:nil];
MYSubclassedNavigationController *mainNav = [[MYSubclassedNavigationController alloc] initWithRootViewController:mainVC];

radioNav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:mainNav animated:YES];
Vinny Coyne
  • 2,365
  • 15
  • 24