Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:13:37+00:00 2026-06-01T23:13:37+00:00

I have a UITabBar with 5 tabs. I only wish to enable autorotation for

  • 0

I have a UITabBar with 5 tabs. I only wish to enable autorotation for a UIViewController that gets pushed onto the stack deep inside tab #3. So to be clear: tap UITabBar item 3, and you get tabbar item #3’s root UIView, which should not autorotate. Tap and get another UIViewController pushed onto the stack (via a UINavigationController). Tap again, and get another UIViewController pushed onto the stack. Only here should this UIView autorotate.

The other 4 tabs should not rotate at all–not the root view of the tabs, nor any of the child views of the tabs.

Can someone tell me what approach I should use? I read that every single tab needs to respond “YES” to willAutorotateToInterfaceOrientation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:13:38+00:00Added an answer on June 1, 2026 at 11:13 pm

    In each view’s shouldAutorotate..., you could call a method in the root view controller that checks what is currently being displayed. If the deep-level view for tab 3 is on display, it will return YES, otherwise NO, and the views will, in turn, return the same.


    Edit — more detail per user798719’s request:

    Your root view controller knows which view is on display. You add a method to the root view controller - (BOOL) isDeepLevelTab3Displayed;. The method checks whether the deep-level view for tab 3 is on display and, if so, returns YES, otherwise returns NO.

    Each sub view controller’s shouldAutorotate… method will get a ref to the root controller so that it can call isDeepLevelTab3Displayed.

    If you’re using a navigation-style controller, you can get the ref like this (self is the sub controller):

    NSArray *arrayOfControllers = [self viewControllers];
    UIViewController *rootController = [arrayOfControllers objectAtIndex:0]; // per UIViewController class ref, root controller is at index 0
    

    Or you could get anything in your project like this:

    YourProjectAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    UIViewController *rootController = appDelegate.rootController; // or appDelegate.intermediateClass1.intermClass2.rootController — however you set up your project
    

    So every sub controller would do this:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {  
        UIViewController *rootController = [[self viewControllers] objectAtIndex:0];
        return [rootController isDeepLevelTab3Displayed];
    }
    

    Therefore, every subcontroller would return YES when autorotation should happen, fulfilling the requirement you mention at the end of your question.

    However, if all your subcontrollers are instances of UINavigationController, you could determine which view is currently on display directly, by calling visibleViewController. Then you just need a way of checking its identity.

    You could check the controller’s nibName or title, for example, against a constant, or add an integer property intControllerIdentity to all your controllers and set them in the controller’s initWithNibName…
    The integer-property scheme might be best, because it won’t be affected should you later change the nibName or title.

    You’d add constants to some class whose h file is imported by all the controllers (or, if all the controllers are instances of the same class, put these constants in that class’s h file):

    #define kFooController 1
    #define kBarController 2
    #define kRotatableController 3
    

    And you’d set it like this:

    self.intControllerIdentity = kRotatableController;
    

    And check it like this:

    if (self.intControllerIdentity == kRotatableController)
    

    Hope that helps. But evaluate this added detail with a critical eye; I have worked with autorotation but not yet with navigation controllers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a UIViewController that has a UITabBar in the view. I want
I have an app, where there's a UITabBar with 5 tabs. When user shakes
I have UITabBar in view which have 5 tabs. I am using didSelectItem delegate
I have a UITableView in a controller that is nested under a UITabBar .
I had 4 UITableView which represents 4 tabs from my UITabBar. So I have
I have a UITabBar. In the first tab, I have a UINavigationController. Within that
I have a UITabBar application, which has three tabs. The first tab has a
I have an application made by a UITabBar with three tabs. One of these
I have a UITabBar Application with two views that load large amounts of data
In my application I have UINavigationController inside UITabBar When I display my HUD the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.