0

I have a Tab Bar app with 5 tabs. I'm using the app delegate to allow landscape orientation in only one tab, and that works fine. The only problem is that after I rotate that view controller, all the other view controllers in the other 4 tabs will all rotate as well.

In my app delegate:

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    if (self.shouldRotate)
        return UIInterfaceOrientationMaskAllButUpsideDown;
    else
        return UIInterfaceOrientationMaskPortrait;
}

In my 4 portrait view controllers:

- (void)viewDidLoad{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    [appDelegate setShouldRotate:NO];
}

In my 1 landscape view controller:

- (void)viewDidLoad {
    [super viewDidLoad];

    [self loadWebViewRequest];

    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    [appDelegate setShouldRotate:YES];
}

Why are my 4 portrait view controllers rotating after the landscape vc rotates?

All the other answers I've seen here don't address how to correctly implement this using a Tab Bar application.

jdlace
  • 341
  • 3
  • 8
  • Most likely their views don't have to be loaded a second time? This really isn't the right approach to restricting particular views to rotate/not rotate however. – nhgrif Jul 12 '15 at 19:20
  • possible duplicate of [Support different orientation for only one view iOS 6](http://stackoverflow.com/questions/12772749/support-different-orientation-for-only-one-view-ios-6) – nhgrif Jul 12 '15 at 19:22
  • @nhgrif This was the only working solution I could find. – jdlace Jul 12 '15 at 19:27
  • @nhgrif Can you recommend the best practices approach to rotate/not rotate? – jdlace Jul 12 '15 at 19:48
  • The question I marked this one as a duplicate of. – nhgrif Jul 12 '15 at 19:54
  • @nhgrif Those solutions aren't coded for a tab bar application. That's what I have. – jdlace Jul 12 '15 at 20:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/83085/discussion-between-jdlace-and-nhgrif). – jdlace Jul 12 '15 at 23:37

0 Answers0