我目前正在开发一个应用程序,当用户将设备旋转到横向视图时,我想从一个屏幕转换到另一个屏幕。我有这个工作,但是当下一个视图进入时,正在转换的屏幕旋转到横向视图。防止当前视图旋转的常见解决方案是为 shouldAutoRotate 方法返回 NO。但是,我需要启用此功能才能过渡到下一个屏幕。我还在 willRotateToInterfaceOrientation 中玩弄了 [UIView setAnimationsEnabled:NO] ,但这只会隐藏动画,并且仍将当前视图旋转为横向。以下是所有相关的旋转方法:
-(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;
}
有什么建议么?提前致谢。