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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:20:44+00:00 2026-05-27T17:20:44+00:00

When I run my app in landscape mode, the second time my view controller’s

  • 0

When I run my app in landscape mode, the second time my view controller’s view is loaded and loadView is called, iOS 5 is not rotating the root view controller’s view away from portrait, nor is it calling the view controller’s willRotate / willAnimateRotation / didRotate methods.

As mentioned, this happens only after the view is unloaded and loadView is called the second time. In my app, I sometimes unload a view controller’s view programmatically before I set it as the root view controller. However, this also happens when the view controller’s view is unloaded automatically due to a low memory warning.

This only happens on iOS 5, not iOS 4.x. It’s easy to reproduce in iOS simulator, and here is a link to a stand-alone test app that reproduces this problem:

http://www.mediafire.com/file/7ob5xw5ym02pasx/ViewControllerTest.zip

To see the issue, just compile the app and start it in landscape mode with iOS 5.0 Simulator, then tap “A” and then “Back”, and you’ll see how the rotation doesn’t occur.

Any ideas? Does this have to do with how I’m setting window.rootViewController?

  • 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-27T17:20:45+00:00Added an answer on May 27, 2026 at 5:20 pm

    I debugged through it and there seems to be a change between 4.3 and 5.0. In 4.3 UIKit calls [UIWindow addRootViewController:], in 5.0 it calls [UIWindow setRootViewController:]. So maybe something changed that we can’t see…

    I’d suggest working around this, by not using [newController setupStuff] (thus not setting the view to nil), but rather overriding

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        // do setup stuff here, reset content etc etc.
    }
    

    and resetting the (already loaded) view, before it actually appears on screen.

    Additional info:

    a) you don’t need to set the view to nil. The system does that for you. When you access the view property of that view controller the next time, the system calls loadView to recreate the view:

    If you access this property and its value is currently nil, the view
    controller automatically calls the loadView method and returns the
    resulting view. The default loadView method attempts to load the view
    from the nib file associated with the view controller (if any).

    b) It all boils down to behavior in iOS 5 regarding the window’s rootViewController property. In iOS 5 these two are not equivalent:

     self.window.rootViewController = newController;
    

    vs

     [self.window.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
     [self.window addSubview:newController.view];
    

    The former completely ignores orientation, the latter doesn’t.

    To make things even more complicated, if one does not override loadView, but instead lets the system auto-create an empty UIView and only modifies that view in viewDidLoad, a memory warning won’t automatically set the view to nil and release it – docs:

    The default implementation releases the view only if it determines that it is safe to do so.
    

    Magic. Depending if one overrides the method or not. I can’t really test this in any way.

    Case 1 – overridden loadView:
    Triggering the memory warning calls bothdidReceiveMemoryWarning and viewDidUnload

    Case 2 – no loadView:
    Triggering the memory warning in simulator only calls didReceiveMemoryWarning, but not viewDidUnload

    I’d say, add the view manually…

    cheers.

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

Sidebar

Related Questions

my app run in landscape mode i want it to be always in one
I am developing an app for iOS 5, which have to run in landscape
i want to run app in landscape and portrait mode, How to check landscape
When I run my app with Leaks and view the Extended Details for any
I'd like to run an app in the KIOSK mode, so that it auto-starts
Just wondering if anybody has run Scala app or web-app on Java Real-Time system?
When I 'grails run-app' each edit of a controller seems to give me a
I'm trying to develop a simple Android app, fixed in landscape mode. I am
I need to preview PDF file, but run viewer in a landscape fixed mode.
I'm working on an iPad app in a split view controller where the app

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.