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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:18:59+00:00 2026-06-15T08:18:59+00:00

Please don’t suggest me it is a bad idea to have the rotation at

  • 0

Please don’t suggest me it is a bad idea to have the rotation at ios 4.3-6.0 in 1 build, because I told to many times and didn’t listen to me.

At project settings I have setted all interface orientations to be supported, just to be sure.

Right now I am testing on ios6 with iphone4. Starting at app delegate it is a code, like this:

mainController = [[MainViewController alloc] initWithNibName:nil bundle:nil];

navigationController=[[RotatingNavigationController alloc] initWithRootViewController:mainController];          
navigationController.navigationBar.hidden =true;

// ios: 4 and 5
//[window addSubview:navigationController.view];

//ios6:
window.rootViewController = navigationController;

[window makeKeyAndVisible];

So I did 2 custom classes, which are recommended in may cases for autorotations, and for they the problem is solved.

The RotatingNavigationController is a custom UINavigationController has a bit ugly code, but I have collected this parts from this forum, so it should be allowed to post it:

@implementation RotatingNavigationController

- (id)init {
    self = [super init];
    if (self) {        
        self.view.autoresizesSubviews = YES;
        [self.view setAutoresizingMask:(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth)];
    }
    return self;
}

// ios6 require this method for rotation detection, available from ios5, ios4.3 not available: sux
//- (void)viewWillLayoutSubviews
//{
    //UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation;

    //[[NSNotificationCenter defaultCenter]     postNotificationName:UIDeviceOrientationDidChangeNotification     object:nil];

//    [[NSNotificationCenter defaultCenter] addObserver:self                                              selector:@selector(orientationChanged:)                                                  name:UIDeviceOrientationDidChangeNotification                                                object:nil];

    /*
    if(UIInterfaceOrientationIsLandscape(statusBarOrientation)){
        [self willRotateToInterfaceOrientation: statusBarOrientation duration: 0.3 ];
    }
    else{
        [self willRotateToInterfaceOrientation: statusBarOrientation duration: 0.3 ];
    }
    */
//}

//ios 4.3 and ios 5.0, at ios6 it isn't called by iOS...sux
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    [self.visibleViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

// //ios 4.3 and ios 5.0, at ios6 need different methods, which sux
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
} 

//Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate methods.


// ios6
- (NSUInteger)supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}

// ios6
- (BOOL)shouldAutorotate
{
    return YES;
}
// ios6
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationMaskPortrait;
}
@end
  • this should generate the autorotation notifications properly, I think he it does his job.

The MainViewController is a custom UIViewController.

just to be sure I have copy-pasted the code:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    //    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
}

// ios6:
- (NSUInteger)supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}

// ios6
- (BOOL)shouldAutorotate
{
    return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationMaskPortrait;
}

His job is to change the different UIViewController based on device state ( rotations )

I have somewhere a Menu screen, which has different xib, but h and m file too ( because has different elements, which doesn’t appear in Portait or Landscape. ( I don’t have the power to change the whole architecture )

A part of the code – and here should be some problem, I think is below in this Maincontroller:

#pragma mark
#pragma mark Rotation
- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation; 

    if(deviceOrientation == UIDeviceOrientationFaceUp || deviceOrientation == UIDeviceOrientationFaceDown){
        if(debug){
            NSLog(@"Nothing to change because it is gone to Flat");
        }
        return;
    }
NSArray *viewControllers = [self.navigationController viewControllers];

if (UIDeviceOrientationIsLandscape(deviceOrientation)){

        //if(debug)
        //    NSLog(@"Portait -> Landscape size : %3.0fw, %3.0fh", self.view.bounds.size.width, self.view.bounds.size.height);
        id lastviewController = viewControllers.lastObject;
        // check what is there:
        if([lastviewController isKindOfClass:[MenuController class]]){                 
            [self.navigationController popViewControllerAnimated:NO];
            [self.navigationController pushViewController:menuLandscape animated:NO];
            NSLog(@"poped Menu Portrait, pushed Menu Landscape");
        }
...
else if(UIDeviceOrientationIsPortrait(deviceOrientation)){
    //else if(UIInterfaceOrientationIsLandscape(statusBarOrientation)){

        //if(debug)
        //    NSLog(@"Landscape -> Portait , size : %3.0fw, %3.0fh", self.view.bounds.size.width, self.view.bounds.size.height);
        id lastviewController = viewControllers.lastObject;
        // check what is there:
        if([lastviewController isKindOfClass:[MenuLandscapeController class]]){
            [self.navigationController popViewControllerAnimated:NO];            
            [self.navigationController pushViewController:menuPortait animated:NO];
        } 
...

The problem is: the landscape is taken out and is pushed the portait, when is upside down, but that portait aren’t rotating and it shows a broken layout.

How can I wake up that controller and tell him is time to rotate, because it isn’t in portrait mode?

Thanks any suggestion related to my question of any improvement beside of architecture change.

Update:

at app delgate doesn’t helped adding the:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    return UIInterfaceOrientationMaskAll;
}

code from other answer: presented here

Update2:

UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation; 

doesn’t want to take the UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown value for some reason, I think that need to be solved.

Update3:
Read very carefully twice and third the ios6 release notes

The system determines whether an orientation is supported by
intersecting the value returned by the app’s
supportedInterfaceOrientationsForWindow: method with the value
returned by the supportedInterfaceOrientations method of the top-most
full-screen controller.

  • now read again 🙂
  • 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-15T08:19:00+00:00Added an answer on June 15, 2026 at 8:19 am

    Add this category to viewcontroller which doesn’t rotate

    @implementation UINavigationController(Rotation)
    
    -(NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskAll;
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please don't close this question before read my actual problem. I have seen many
I am trying to build a better var_dump() (please don't suggest alternatives; there is
I have mutipule web projects (please don't ask me why with multipule namespaces within
I have a flash element (I know, but please don't) with a settings.xml file.
Please don't be deterred by the just another IE problem. I have a custom
I have a VB6 application (please don't laugh) which does a lot of drawing
I am fairly new to MVC so please don't hesitate to suggest a better/cleaner/simpler
Say I have a normal CSV like # helloworld.csv hello,world,,,please don't replace quoted stuff
please don't mind my question since I don't know much about software because I
Please don't suggest I stop using <input type=submit> I need to support non javascript-enabled

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.