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 1086489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:49:11+00:00 2026-05-16T22:49:11+00:00

I have a TabbarController with different ViewControllers. Some of these ViewControllers should autorotate and

  • 0

I have a TabbarController with different ViewControllers.
Some of these ViewControllers should autorotate and one ViewController should be presented only in PORTRAIT.
I fill the Tabbar with the following procedure:

ChartThemeViewController *chartViewController = [[ChartThemeViewController alloc] 
                                                           initWithTheme:chartThemeDict];
UINavigationController *theNavigationController = [[UINavigationController alloc] 
                                                           initWithRootViewController:chartViewController];
[chartViewController release];
[localViewControllersArray addObject:theNavigationController];
[theNavigationController release];

tabBarController.viewControllers = localViewControllersArray;

The ChartThemeViewController is a subclass of ThemeViewController.
ThemeViewController is a subclass of UIViewController.

If I override ‘shouldAutorotateToInterfaceOrientation’ in the subclasses of ThemeViewController, and return YES in all subclasses and return NO in ChartThemeViewController… it happens that all the ViewControllers don’t autorotate.

mmmmhhh… hope you can understand this…

How can I solve this problem?

many thanks
jens

  • 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-05-16T22:49:11+00:00Added an answer on May 16, 2026 at 10:49 pm

    I believe the trick to selective autorotation within an instance of UITabBarController is as follows: Subclass UITabBarController and override the method -(BOOL)shouldAutorotateToInterfaceOrientation: with the following:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return [[self selectedViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    };
    

    Now, if you select your portrait-only tab and rotate to landscape, the application will stay in portrait.

    A new problem here, though, is as follows: select a tab that does support landscape; rotate to landscape; select a tab that only supports portrait. Uh oh. The portrait-only view controller is being displayed in landscape. Unfortunately, there is no way to force a view controller to a specific orientation.

    You can look here for a description of the problem: How to force a screen orientation in specific view controllers?

    As you can see, there is no real solution.

    I would recommend disabling all tabs that do not support the current orientation. You can override -(void)didAutorotateToInterfaceOrientation: in your UITabBarController subclass with the following to achieve this:

    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    {
        UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
        NSArray *items = [[self tabBar] items];
        for (NSUInteger i = 0; i < [items count]; i ++)
        {
            UITabBarItem *item = [items objectAtIndex:i];
            if (![[[self viewControllers] objectAtIndex:i] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation])
            {
                [item setEnabled:NO];
            }
            else
            {
                [item setEnabled:YES];
            };
        };
    };
    

    If you do not wish to do this, then consider altering your interface to be able to support the same orientations in all of your view controllers.

    Hope this helps,

    Ryan

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

Sidebar

Related Questions

I have a TabBarController with 4 views, and one of them is a scrollView.
Okay, what I currently have is a TabBarController with five tabs. Each of these
I have a tabbar based application. The tabbarcontroller is on the top of the
I have a script that appends some rows to a table. One of the
I have a UIImageView as one of my tabbarcontroller views, and I've added a
I have 5 different tabs in my tabbar controller. My intention is to be
I have a TabBarController, which consists of three tabs, one of which is the
I have a simple UIViewController with just a UIWebView. The UIWebView should take all
i have a 3 tabbar in my app. in my Appdelegate i have a
I have two different view controllers added to the view controllers array of a

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.