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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:17:43+00:00 2026-06-11T21:17:43+00:00

In many situation need to rotate the controller and is not working. Right now

  • 0

In many situation need to rotate the controller and is not working.
Right now I have the inverse of the problem: it is rotating, and I want to disable.

In that ViewController I have this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

but it is auto-rotating, because not this UIViewController is asked, but his parent in UI tree. Maybe that is the problem. The root controller must return Yes for all cases, because there are a few other UIViewControllers on the stack, which has / must have Portait / Landscape support.

I can’t / don’t want to touch other parts, because … there are several reasons, for eg: the app is huge, with lot of know bugs and I don’t want to make 1 and test it for 1 week, other is the deadline.

Please don’t suggest it shouldn’t be like this and must rewritten. I know.

How to deal with this controller to force Portait ?

Please read the bolded text too: can’t force the whole app to support only Portait for 1 view controller, there are many on stack!

  • 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-11T21:17:44+00:00Added an answer on June 11, 2026 at 9:17 pm

    detect the Landscape rotation and rotate to Portait:

    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    { 
    
        UIInterfaceOrientation appOrientation = [UIApplication sharedApplication].statusBarOrientation;
        float width = self.view.bounds.size.width;
        float height = self.view.bounds.size.height;
        //NSLog(@"width %3.0f, height: %3.0f", width, height);
    
        if((fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
            // if is rotated from Portait:
            if((appOrientation == UIInterfaceOrientationLandscapeLeft || appOrientation == UIInterfaceOrientationLandscapeRight)){
                // to Landscape:
                CGAffineTransform transform = self.view.transform;
                transform = CGAffineTransformRotate(transform, -(M_PI / 2.0));
                self.view.transform = transform;            
    
                [self.view setBounds:CGRectMake(0, 0, height, width)];
            }
        }
        else {
            // it is rotated from Landscape:
            if((appOrientation == UIInterfaceOrientationPortrait || appOrientation == UIInterfaceOrientationPortraitUpsideDown)){
                // to Portrait:            
                CGAffineTransform transform = self.view.transform;
                transform = CGAffineTransformRotate(transform, +(M_PI / 2.0));
                self.view.transform = transform;            
    
                [self.view setBounds:CGRectMake(0, 0, height, width)];
            }
        } 
    }
    

    it isn’t the best programming paradigm, but it does the trick.

    Somebody write similar like tis to accept his answer, or write a better method, if you can!

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

Sidebar

Related Questions

I'm working with vector now and I have an interesting situation which I need
Working with a relatively large data set I have a situation where I need
Situation: I have many gzipped input files that I want to process in a
I have worked with various applications and encountered this situation many times. Until now
I'm writing an app, and in many situations need to have direct access to
I have a situation where my main SWF file loads many external SWF files.
Here is my situation: I have a C project linking with many libraries (I
I have a one-to-many relationship between two classes for this situation. I have a
I have a situation where I need to use some strings temporarily but I've
I have a situation where I need to make some data available for reading

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.