1

我目前正在开发一个应用程序,当用户将设备旋转到横向视图时,我想从一个屏幕转换到另一个屏幕。我有这个工作,但是当下一个视图进入时,正在转换的屏幕旋转到横向视图。防止当前视图旋转的常见解决方案是为 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;
}

有什么建议么?提前致谢。

4

1 回答 1

0

您需要配置在旋转时动画化的视图,以不响应方向/大小的变化。例如,查看界面构建器中的自动布局设置,或者可能是 struts/springs 设置,如果您不使用自动布局(这是一种较新的技术)。

于 2013-03-03T09:20:32.670 回答