简体   繁体   中英

iPhone Autorotation - Disable view rotation animation BUT transitions to another screen

I am currently working on an app where I would like to transition from one screen to another when the user rotates the device to landscape view. I have this working, but the screen that is being transitioned out rotates to landscape view just as the next view is coming in. A common solution to preventing the current view from rotating is to return NO for the shouldAutoRotate method. However, I need this enabled in order to transition to the next screen. I've also toyed with [UIView setAnimationsEnabled:NO] in the willRotateToInterfaceOrientation but this only hides the animation, and still rotates the current view to landscape. Here are all related rotate methods:

-(BOOL)shouldAutorotate
{
        return YES;
}

//Temporarily disable rotation animation
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [UIView setAnimationsEnabled:NO];
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [UIView setAnimationsEnabled:YES];

    if(UIInterfaceOrientationLandscapeLeft)
        [self performSegueWithIdentifier:@"landscapeView" sender:self];
}


-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

Any suggestions? Thanks in advance.

You need to configure the view that is animating out at rotation time to not respond to changes in orientation/size. See, for example, your autolayout settings in interface builder, or possibly the struts/springs settings, if you're not using autolayout (which a newer technology).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM