我正在开发一个应用,当用户将设备旋转到横向视图时,我希望从一个屏幕转换到另一个屏幕。我有这个工作,但正在转换的屏幕旋转到横向视图就像下一个视图进来。防止当前视图旋转的常见解决方案是为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;
}
有什么建议吗?提前谢谢。
答案 0 :(得分:0)
您需要配置在旋转时设置动画的视图,以便不响应方向/大小的更改。例如,如果您没有使用autolayout(更新的技术),请参阅界面构建器中的自动布局设置,或者可能是struts / spring设置。