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

  • Home
  • SEARCH
  • 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 6801073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:03:18+00:00 2026-05-26T19:03:18+00:00

I am using a tab bar controller for my app. If I’m in one

  • 0

I am using a tab bar controller for my app. If I’m in one of the view controllers called “results” and the ios device rotates to landscape mode, it switches for another view I created called landScape. This has been done within the method

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrient‌​ation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    {
        self.view=landScape;
    } else {
        self.view=originalView;
    }
}

It works just fine whenever I am in that specific controller within the tab bar (example results view controller). However; If I go to another element in my tab bar controller and my phone is tilted in landscape mode and then I decide to go to resultsviewcontroller, it does not call upon my view landScape, instead it tries to autosize the view on its own and it looks awful. Should I call the method -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration within my viewDidLoad method to solve the problem? Or is this completely wrong?

Thank you in advance!

  • 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-26T19:03:19+00:00Added an answer on May 26, 2026 at 7:03 pm

    The problem is you’re only setting resultsViewController.view when it is the active view controller and detects a rotation. Try this:

    - (void)setViewForInterfaceOrientation:(UIInterfaceOrientation)orientation
    {
        self.view = UIInterfaceOrientationIsPortrait(orientation)
            ? originalView
            : landScape;
    }
    
    - (void)viewWillAppear
    {
        [self setViewForInterfaceOrientation:[[UIDevice currentDevice] orientation];
        [super viewWillAppear];
    }
    
    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrient‌​ation duration:(NSTimeInterval)duration
    {
        [self setViewForInterfaceOrientation:toInterfaceOrientation];
        [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app is using a tab bar controller with two tab bar items: Each
I am using a tab bar controller in my app but I load a
I have an app with 3 views. I am using a tab bar controller
I need to present a modal tab bar controller using interface builder. I'd like
i am using tab bar control in my app and want to use the
I am using a tab bar (UITabBarController) on my app and I wish to
I have a multiview application using a tab bar to switch views. One is
I have setup tab bar controller using interface builder, and each tab bar item
My app has two distincts modes. There's a tab bar controller in the app
I have an app with a tab bar. Each tab has its own view

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.