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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:20:58+00:00 2026-06-14T10:20:58+00:00

I have a view-controller that I’m re-using (for memory limitation reasons.) So, rather than

  • 0

I have a view-controller that I’m re-using (for memory limitation reasons.) So, rather than push a new UIViewController, I just set a few parameters, then force this VC to reload its view. The code is something like this (triggered by a Notification callback):

- (void) reloadView: (NSNotification*) note
{
    // Save parameters for reloaded view
    UIWindow *window = (UIWindow*) self.view.superview;
    //CGAffineTransform xfrm = self.view.transform;  // Doesn't do what I want.

    // Trash this one & reload the view
    [self.view removeFromSuperview];
    self.view = nil;

    // force view reload
    if (self.view == nil)
    {
        NSLog(@"%s ***** Why didn't self.view reload?!", __PRETTY_FUNCTION__);
    }
    else
    {
        // restore params
        //self.view.transform = xfrm;  // Boo-hoo!
        [window addSubview: self.view];
    }
}

Everything works fine except that the app is landscape only, and the newly reloaded view is added to the Window as portrait.

I tried forcing the old view’s transform onto the new view but, oddly, it gave the rotation but a goofy translation offset.

Is there a way to tell a UIViewController “do your rotation, now”…?

EDIT:

I added this rather silly hack:

    // restore params
    self.view.transform = xfrm;
    self.view.center = CGPointMake(window.bounds.size.width / 2., window.bounds.size.height / 2.);
    [window addSubview: self.view];

which gives the desired result, but I’m really displeased with having such a thing in my code base. Surely there’s a better way to do this?!?!

Thanks!

EDIT:

After some discussion with JPH, then answer turned out to be “don’t do things that way.” See comments for some of the details and the redesign that took place.

  • 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-14T10:20:59+00:00Added an answer on June 14, 2026 at 10:20 am

    Your problem is in using this:

    [window addSubview: self.view];
    

    From the documentation:

    If you add an additional view controller’s UIView property to UIWindow
    (at the same level as your primary view controller) via the following:

    [myWindow addSubview:anotherController.view];

    this additional view controller will not receive rotation events and
    will never rotate. Only the first view controller added to UIWindow
    will rotate.

    https://developer.apple.com/library/ios/#qa/qa2010/qa1688.html

    I would much prefer a design with a root view controller and the subviews being added to the root view controller’s view.

    Another option is to NOT kill the view and re-add it, but rather update everything that needs to be updated in that view. I am not sure I understand why you would want to kill a view and re-add it right away.

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

Sidebar

Related Questions

I have a view controller that i'm trying to push onto the navigation stack.
I have a view controller that was presented using [self presentModalViewController:myVC animated:YES]; this VC
I have a modal view controller that I put onto screen using presentModalViewController:animated .
I have a modal view controller that takes another UIViewController as delegate. My doubt
I have a view controller that houses a UIWebView. I want to display an
I have a view controller that gets presented modally and changes some data that
I have a view controller that has a tableView in it. When I set
If I have a view controller that has an NSOperationQueue as an instance variable,
I know this is extremely silly. I have a view controller that scans a
In a word, how? I have a view controller that creates a few custom

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.