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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:39:17+00:00 2026-05-20T00:39:17+00:00

Greetings! Here’s the scenario. Starting with a navigation controller (and no tab bar is

  • 0

Greetings! Here’s the scenario.

Starting with a navigation controller (and no tab bar is present – it is hidden from a previous view controller push), I init a new view controller and push it onto the nav controller stack. This new VC contains a lonesome UIView into which I programmatically add a UIScrollView with the same frame. (I wanted to avoid the UIView, but this was the only way I could get self.view to be assigned to something. I suspect casting a UIScrollView to UIView in viewDidLoad is not advisable.)

So now we have a nav bar, and a scroll view. I’ve set it up to scroll through some images (big surprise, I know!), and that works just fine. Now I want this to support autorotation. So I respond in the VC like so:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

Compile and run. Aaaand … nothing. Obviously I’ve done something wrong.

Now, I’ve already read the post regarding UINavigationController and autorotation, and I get the sneaking suspicion that I’m going about this the wrong way, and making it way more complicated than necessary.

There’s got to be a better way to present a UIScrollView that supports autorotation. Perhaps the Nav Controller is getting in the way, but I’m not sure how to get around it.

Ideally, I’d like something without any kind of nav bar showing. Instead, we have a toolbar/status bar that appears/hides from the top (like you see when playing video). If the nav bar must remain – or if that’s REALLY a shorter-height nav bar I’m seeing when playing video vs. a toolbar, however do I get the thing to rotate around? The thing is, I only want it to rotate in this particular mode, when viewing the pix. Not at any other time.

Dare I try using a modal VC? (Yeccch – no, that can’t be right either. Plus it has a nav bar anyway.)

  • 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-20T00:39:18+00:00Added an answer on May 20, 2026 at 12:39 am

    You can solve this without subclassing by creating a UITabBarController category.

    Here is the category implementation which handles my case where I have anonymous UINavigationControllers associated with my tabs and custom UIViewController subclasses as the root view controllers of the UINavigationControllers:

    @implementation UITabBarController (Rotation)
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    {   
        if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) {
            UIViewController *rootController = [((UINavigationController *)self.selectedViewController).viewControllers objectAtIndex:0];
            return [rootController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
        }
        return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    }
    
    @end
    

    I also have a category on UINavigationController which defaults to returning YES. So, the default behavior is to enable rotation and I can return NO from shouldAutorotateToInterfaceOrientation:interfaceOrientation for just the controllers and orientations for which I wish to disable rotation.

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

Sidebar

Related Questions

Greetings, Here's the problem I'm having. I have a page which redirects directly to
Greetings to all! This is my first question here on stackoverflow. I have a
Greetings everyone. This is my first question here at stackoverflow so please bear with
I am new here so first of all my greetings to you I am
Greetings everyone. I'm in need of some experiance here as how to deal with
Greetings all, I have some JSON code that looks like this: { playlist: [
Greetings guys, hopefully somebody has fresher eyes and can help me pinpoint the problem
Greetings again, and thanks once more to all of you who provided answers to
Greetings, I am trying to learn pointers in C, I simply want my addtwo
Greetings! I want to use LINQ to query a list of objects and sort

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.