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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:19:22+00:00 2026-05-27T09:19:22+00:00

I’m working on an iphone app with a TabBarController as rootcontroller. And this rootcontroller

  • 0

I’m working on an iphone app with a TabBarController as rootcontroller. And this rootcontroller is associated to Navigation Controllers (each one related to a specific Tab Bar button).

One on these navigation controllers shows some photos and thus I needed to enable Lanscape which obviously did not work until I added this code to all view controllers

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

However, now that all orientations are enabled in all views some views I didn’t want in landscape are showing very ugly 🙁

Any idea how to just leave the landscape orienation only on this photo view and disable it on all other views?

  • 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-27T09:19:23+00:00Added an answer on May 27, 2026 at 9:19 am

    Consider showing the UIViewController that needs full reorientation capabilities modally.
    That would be the common and in my humble opinion correct way to handle such situation.

    To answer your subject in short: yes, it does have to return YES if you want any of the tabbed viewControllers to allow reorientation. The same goes for viewControllers within the stack of your UINavigationControllers. Hence the same goes for any combination of those.

    From Apple’s Technical Note on that subject:

    Why won’t my UIViewController rotate with the device?

    All child view controllers in your UITabBarController or
    UINavigationController do not agree on a common orientation set. To
    make sure that all your child view controllers rotate correctly, you
    must implement shouldAutorotateToInterfaceOrientation for each view
    controller representing each tab or navigation level. Each must agree
    on the same orientation for that rotate to occur. That is, they all
    should return YES for the same orientation positions.

    In case using a modally presented view controller is no option for you – here comes another way…

    There is also a solution possible that seems a little “hacky” but worked for me in the past. I will draft it in a very very “hacky” way to simplify the answer.

    Within the shouldAutorotateToInterfaceOrientation:toInterfaceOrientation implementation of all of your viewControllers, return a global value. Change that global value according to the needs of the currently displayed viewController. Even though it is said that a viewController is only asked once, this common rumor has proven untrue for my. So here comes the super hack;

    All view controllers within your navigation stack should implement the shouldAutorotate-method like this:

    - (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)toInterfaceOrientation
    {
        extern BOOL gSouldAutorotateToAnyOrientationFlag;
        if (gShouldAutorotateToAnyOrientationFlag)
        {
            return YES;
        }
        return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);   
    }
    

    Now, somewhere in your app, you should declare and instantiate that global flag – you could place this ugly global flag within your app-delegate implementation, directly below the imports and above the @implementation block:

    BOOL gShouldAutorotateToAnyOrientationFlag = NO;
    

    Within all viewControllers that are supposed to be shown in portrait mode only, set that flag towards NO – e.g. within viewWillAppear;

    - (void)viewWillAppear:(BOOL)animated
    {
        extern BOOL gShouldAutorotateToAnyOrientationFlag;
        gShouldAutorotateToAnyOrientationFlag = NO;   
    }
    

    Within the viewController/s that are supposed to be shown in any orientation, set that flag towards YES – again within viewWillAppear;

    - (void)viewWillAppear:(BOOL)animated
    {
        extern BOOL gShouldAutorotateToAnyOrientationFlag;
        gShouldAutorotateToAnyOrientationFlag = YES;   
    }
    

    That way, whenever the entire navigation stack is asked for its orientation capabilities, the proper answer will be given. From my experience, the entire stack is asked, over and over again and answers are not cached, hence my hack worked whenever I needed it. Still, the rumor seems to be widespread that those answers are somehow cached and therefor that rumor might be valid in certain cases – hence I shall not be held responsible if this does not work for you (or even down voted 😀 )

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.