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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:13:39+00:00 2026-05-22T21:13:39+00:00

I have a project where the rotation events stop firing after removing/adding a lot

  • 0

I have a project where the rotation events stop firing after removing/adding a lot of view/viewControllers. It works for a while and then at random the new view added to the window never gets shouldAutorotateToInterfaceOrientation: called.

The status bar fails to rotate as well but the view/view controller functions normal (minus rotation). Also there is only one view / viewController added to the window at a time. I’m assuming a old viewController is registered as key but everything added to window is a subclass of view controller and none of the subclasses are showing up in instrument allocations except the active one.

Is there a way on the app delegate or window to find which view controller is key?

Is there any other reason why the shouldAutorotateToInterfaceOrientation: could be failing to get called?

Each view controller is implementing:

- (BOOL)shouldAutorotateToInterfaceOrientation:

(UIInterfaceOrientation)interfaceOrientation {
return YES;
}

- (void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) 
                     interfaceOrientation duration: (NSTimeInterval) duration {
    //manual rotation code
}

Here is the code I’m using in the application delegate to change the root view controller and the displayed view.

[UIView transitionWithView:new.view 
                  duration:0.3
                   options:UIViewAnimationOptionCurveEaseOut
                animations:^{
                    //add new view
                    [self.window addSubview:new.view];

                    //play transition animation for old and new views
                    new.view.transform = CGAffineTransformConcat(new.view.transform, newEnd);
                    old.view.transform = CGAffineTransformConcat(old.view.transform, oldEnd);

                    //if old view is a "modal style" then keep it in front on new view
                    if([old conformsToProtocol:@protocol(PreloadableModalView)]) {
                        [self.window bringSubviewToFront:old.view];
                    }

                }
                completion:^(BOOL finished){
                    //remove old view
                    [old removeSubviews];
                    [old.view removeFromSuperview];
                }];
  • 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-22T21:13:40+00:00Added an answer on May 22, 2026 at 9:13 pm

    It looks like the root of the problem was that removing the viewController that the window was sending the rotation event during the transition caused the window to sometimes not register the new viewcontroller as the new root.

    I just have one UIView (with its own UIViewController) added to the Window. During the animation I was removing the root view controller and adding a new one to the screen. The fix was to switch view controllers before the animation.

    1. I created a screenshot of the current view

    2. removed the old view controller

    3. set the new view controller as the rootviewcontroller and add the view to the window

    4. ran the transition animation

    5. oncomplete i delete the image

    this is the main parts of the code:

    //create a image of old view and add to window
    UIGraphicsBeginImageContext(old.view.bounds.size);
    [[old.view layer] renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageView *screenshot = [[UIImageView alloc] initWithImage:snapshot];
    [self.window addSubview:screenshot];
    [screenshot release];
    
    //remove view and viewcontroller
    [old.view removeFromSuperview];
    
    //set new viewcontroller as root
    if(self.window.rootViewController)
        self.window.rootViewController = nil;
    self.window.rootViewController = new;
    
    //transition code goes here
    
    
    //animate
    [UIView transitionWithView:new.view 
                      duration:0.5
                       options:UIViewAnimationOptionCurveEaseOut
                    animations:^{
    
                        //add new view
                        [self.window addSubview:new.view];
    
                        //play transition animation
                        if(isOldModalDisplay) {
                            screenshot.transform = CGAffineTransformConcat(new.view.transform, newEnd);
                            [self.window bringSubviewToFront:screenshot];
                        } else {
                            new.view.transform = CGAffineTransformConcat(new.view.transform, newEnd);
                        }
                    }
                    completion:^(BOOL finished){
                        //remove screenshot
                        [screenshot removeFromSuperview];
                    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have project written in Zend Framework and it works fine most of environments.
I have an iPad project structured as: - AppDelegate - MainWindow - View Controller
I have project asp.net with namespace test and I'm using resources (files Resource.resx and
I have project I want to upgrade to .Net4 and it use BackgroundCopyManager.dll. Anyone
I have project on rails 3 with multiplayer using Faye. The error block in
I have project Emle in Launchpad . I set it to import from emle.svn.sourceforge.net
I have project in Dropbox and two running laptops: one with Ubuntu and one
folks! I have project in cc.net and this project nay start by 3 ways
I am using Spring and Maven project. I have Project mit-webservices and mit-util project
I am very desperate now... I have project in Visual C++ 2010 using Qt

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.