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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:33:49+00:00 2026-06-12T02:33:49+00:00

I have a UITabBarViewController in portrait mode where I push a modalViewController in landscape.

  • 0

I have a UITabBarViewController in portrait mode where I push a modalViewController in landscape. The rotation changes to landscape when I push the modal, but when I dismiss it the orientation remains in landscape instead of reverting to portrait.

Code:

a CustomUINavigationController for the landscape mode:

- (BOOL)shouldAutorotate
{
  return [[self.viewControllers lastObject] shouldAutorotate];
}

- (NSUInteger)supportedInterfaceOrientations
{
  return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

the uitabbarcontroller

- (BOOL)shouldAutorotate
{
  if ([self inModal]) {
    UINavigationController *nav = (UINavigationController *)self.modalViewController;
    return [[nav.viewControllers lastObject] shouldAutorotate];
  } else {
    return NO;
  }
}

-(NSUInteger)supportedInterfaceOrientations
{
  if ([self inModal]) {
    UINavigationController *nav = (UINavigationController *)self.modalViewController;
    return [[nav.viewControllers lastObject] supportedInterfaceOrientations];
  } else {
    return UIInterfaceOrientationPortrait;
  }    
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  if ([self inModal]) {
    UINavigationController *nav = (UINavigationController *)self.modalViewController;
    return [[nav.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
  } else {
    return UIInterfaceOrientationPortrait;
  }
}

- (BOOL)inModal
{
  if (self.modalViewController && [self.modalViewController isKindOfClass:[UINavigationController class]]) {
    return YES;
  } else {
    return NO;
  }    
}

If I set shouldRotate to YES I get an error: * Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES. Even though I have set the two orientations in UISupportedDeviceOrientations.

  • 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-12T02:33:50+00:00Added an answer on June 12, 2026 at 2:33 am

    I think your problem is caused by this line (you have it twice in your code):

    return UIInterfaceOrientationPortrait;
    

    I’m currently trying to do s.th. similar to what you try to achieve, and have asked my question here: iOS 6 auto rotation issue – supportedInterfaceOrientations return value not respected

    The problem with your code is that the two methods don’t return an interface orientation but rather a mask that encodes in its bits a combination of allowed or preferred orientations.

    Try this:

    return UIInterfaceOrientationMaskPortrait;
    

    UIInterfaceOrientationPortrait is mapped to 0 as far as I know and is thus interpreted as the empty set of interface orientations (none).

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

Sidebar

Related Questions

Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
Have searched for the answer but no joy, so here goes... I'm working on
I have UITabBarViewController which has 2 views. The first view has a UITableView which
Have been having an issue sine using the HABTM relationship in models instead of
I have a loginViewController as root. After login I want to set UITabBarViewController as
Have a recurring situation, petty I know, but I'd like to consolidate the following:
Have a spreadsheet where the ordering of the worksheets may arbitrarily change, but not
Have copy pasted the code from Blog tutorial in cakephp 2.2 but its not
have now tried using this code but keep getting a null value when I

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.