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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:09:28+00:00 2026-06-12T12:09:28+00:00

I gave an app with say 10 view controllers. I use navigation controller to

  • 0

I gave an app with say 10 view controllers. I use navigation controller to load/unload them.

All but one are in portrait mode. Suppose the 7th VC is in landscape. I need it to be presented in landscape when it gets loaded.

Please suggest a way to force the orientation go from portrait to landscape in IOS 6 (and it will be good to work in IOS 5 as well).

Here is how I was doing it BEFORE IOS 6:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UIViewController *c = [[[UIViewController alloc]init] autorelease];
    [self presentModalViewController:c animated:NO];
    [self dismissModalViewControllerAnimated:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Presenting and dismissing a modal VC was forcing the app to review its orientation, so shouldAutorotateToInterfaceOrientation was getting called.

What I have have tried in IOS 6:

- (BOOL)shouldAutorotate{
    return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeLeft;
}

On load, the controller keeps staying in portrait. After rotating the device, the orientation changes just ok. But I need to make the controller to rotate automatically to landscape on load, thus the user will have to rotate the device to see the data correctly.

Another problem: after rotating the device back to portrait, the orientation goes to portrait, although I have specified in supportedInterfaceOrientations only UIInterfaceOrientationMaskLandscape. Why it happens?

Also, NONE of above 3 methods are getting called.

Some (useful) data:

  1. In my plist file I have specified 3 orientations – all but upside down.
  2. The project was started in Xcode 4.3 IOS 5. All classes including xibs were created before Xcode 4.5 IOS 6, now I use the last version.
  3. In plist file the status bar is set to visible.
  4. In xib file (the one I want to be in landscape) the status bar is “None”, the orientation is set to landscape.

Any help is appreciated. Thanks.

  • 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-12T12:09:29+00:00Added an answer on June 12, 2026 at 12:09 pm

    Ok, folks, I will post my solution.

    What I have:

    1. A view based application, with several view controllers. (It was navigation based, but I had to make it view based, due to orientation issues).
    2. All view controllers are portrait, except one – landscapeLeft.

    Tasks:

    1. One of my view controllers must automatically rotate to landscape, no matter how the user holds the device. All other controllers must be portrait, and after leaving the landscape controller, the app must force rotate to portrait, no matter, again, how the user holds the device.
    2. This must work as on IOS 6.x as on IOS 5.x

    Go!

    (Update Removed the macros suggested by @Ivan Vučica)

    In all your PORTRAIT view controllers override autorotation methods like this:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
        return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
    }
    -(BOOL)shouldAutorotate {
        return YES;
    }
    - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskPortrait;
    }
    

    You can see the 2 approaches: one for IOS 5 and another For IOS 6.

    The same for your LANDSCAPE view controller, with some additions and changes:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
        [image_signature setImage:[self resizeImage:image_signature.image]];
        return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    -(BOOL)shouldAutorotate {
        return YES;
    }
    - (NSUInteger)supportedInterfaceOrientations {
        [image_signature setImage:[self resizeImage:image_signature.image]];
        return UIInterfaceOrientationMaskLandscapeLeft;
    }
    

    ATTENTION: to force autorotation in IOS 5 you should add this:

    - (void)viewDidLoad{
        [super viewDidLoad];
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0)
            [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];    
    }
    

    Analogically, after you leave the LANDSCAPE controller, whatever controller you load, you should force again autorotation for IOS 5, but now you will use UIDeviceOrientationPortrait, as you go to a PORTRAIT controller:

    - (void)viewDidLoad{
            [super viewDidLoad];
            if ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0)
                [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];    
        }
    

    Now the last thing (and it’s a bit weird) – you have to change the way you switch from a controller to another, depending on the IOS:

    Make an NSObject class “Schalter” (“Switch” from German).

    In Schalter.h say:

    #import <Foundation/Foundation.h>
    
    @interface Schalter : NSObject
    + (void)loadController:(UIViewController*)VControllerToLoad andRelease:(UIViewController*)VControllerToRelease;
    @end
    

    In Schalter.m say:

    #import "Schalter.h"
    #import "AppDelegate.h"
    
    @implementation Schalter
    + (void)loadController:(UIViewController*)VControllerToLoad andRelease:(UIViewController*)VControllerToRelease{
    
        //adjust the frame of the new controller
        CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
        CGRect windowFrame = [[UIScreen mainScreen] bounds];
        CGRect firstViewFrame = CGRectMake(statusBarFrame.origin.x, statusBarFrame.size.height, windowFrame.size.width, windowFrame.size.height - statusBarFrame.size.height);
        VControllerToLoad.view.frame = firstViewFrame;
    
        //check version and go
        if (IOS_OLDER_THAN_6)
            [((AppDelegate*)[UIApplication sharedApplication].delegate).window addSubview:VControllerToLoad.view];
        else
            [((AppDelegate*)[UIApplication sharedApplication].delegate).window setRootViewController:VControllerToLoad];
    
        //kill the previous view controller
        [VControllerToRelease.view removeFromSuperview];
    }
    @end
    

    NOW, this is the way you use Schalter ( suppose you go from Warehouse controller to Products controller ) :

    #import "Warehouse.h"
    #import "Products.h"
    
    @implementation Warehouse
    Products *instance_to_products;
    
    - (void)goToProducts{
        instance_to_products = [[Products alloc] init];
        [Schalter loadController:instance_to_products andRelease:self];
    }
    
    bla-bla-bla your methods
    
    @end
    

    Of course you must release instance_to_products object:

    - (void)dealloc{
         [instance_to_products release];
         [super dealloc];
    }
    

    Well, this is it. Don’t hesitate to downvote, I don’t care. This is for the ones who are looking for solutions, not for reputation.
    Cheers!
    Sava Mazare.

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

Sidebar

Related Questions

Let's say we have an app which has a lot of view controllers and
I have CLLocation variable declared i gave it a value but when i use
On an App v1.0 I gave the user the possibility to add data on
My android app leaks, what should I check? I gave a look at avoiding
I gave to Google Guice the responsibility of wiring my objects. But, how can
I have app with two sites, one where design is done and other which
I'm creating a new app and I want to use some libraries like this:
I have 2 activities lets say A and B. In the first one(A) I
I am doing building an application for an app-store market. They gave me following
I have localised the whole app but not able to localise the date picker.

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.