[英]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.
我已经完成了这项工作,但是要移出的屏幕正好在进入下一个视图时旋转到横向视图。防止当前视图旋转的常见解决方案是为shouldAutoRotate方法返回NO。 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.
我还用willRotateToInterfaceOrientation中的[UIView setAnimationsEnabled:NO]进行了设置,但这仅隐藏了动画,并且仍将当前视图旋转为横向。 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).
例如,如果您不使用自动布局(这是一种较新的技术),请参阅“界面生成器”中的自动布局设置,或查看struts / springs设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.