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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:03:36+00:00 2026-05-23T13:03:36+00:00

I am displaying a modal view controller when I rotate landscape. I want to

  • 0

I am displaying a modal view controller when I rotate landscape. I want to remove the modal view controller when I am in portrait. For some reason, my log statement doesn’t appear when I go into portrait mode.

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


-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {

        NSLog(@"showing chart");
        [self presentModalViewController:landscapeChartViewController animated:NO];
    }

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
        toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        NSLog(@"dismissing chart");
        [self.parentViewController dismissModalViewControllerAnimated:NO];
    }
}
  • 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-23T13:03:37+00:00Added an answer on May 23, 2026 at 1:03 pm

    You can simplify this code a bit, might help narrow it down.

     - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return YES; // Return YES is the same as entering all interfaces.
    }
    
    
    -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
    
        NSLog(@"showing chart");
        [self presentModalViewController:landscapeChartViewController animated:NO];
    }
    
    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
        NSLog(@"dismissing chart");
        [self.parentViewController dismissModalViewControllerAnimated:NO];
        // self.parentViewController seems like a call FROM the modalViewController. 
        // This should be moved to the modalViewControllers implementation
    }
    }
    

    Just from looking at it, I’m thinking you need to dismiss the modal view controller inside the modal view, not inside the parent view. So, you would use the landscape version inside your primary controller, and then add the “willAnimateRotation…” to the modal controller to handle the portrait rotation state.

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

Sidebar

Related Questions

I am displaying a modal view with [self presentModalViewController:controller animated:YES]; When the view moves
in an iPad application, I am displaying a modal view controller (through presentModalViewController )
I am displaying a modal view controller from an NSObject. I call presentModalViewController:animated on
I have an issue with a particular controller action not displaying the view. Here
I have an array controller holding some values, say - subjects. I am displaying
I need some help with modal view controllers, as I have not used Modal
I have a modal view controller that I am trying to present a web
I'm trying to add a button to a modal view controller so it can
I am displaying a view controller as a popover on button click, and it
I am displaying a UIWebview in a view controller that is presented as a

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.