1

在我的 rootViewController 中,我重新实现了shouldAutorotateToInterfaceOrientation这样的方法。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    switch (toInterfaceOrientation) {
        case UIInterfaceOrientationPortrait:
            NSLog(@"Orientation - Portrait");
            break;
        case UIInterfaceOrientationLandscapeLeft:          
            NSLog(@"Orientation - Left");
            break;
        case UIInterfaceOrientationLandscapeRight:
            NSLog(@"Orientation - Right");
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            NSLog(@"Orientation - UpsideDown");
            break;
        default:
            break;
    }
    return YES;
}

当我旋转我的设备时,会为 LandscapeRight、LandscapeLeft 和 UpsideDown 调用此方法,但不会为纵向方向调用此方法。

在启动时视图处于纵向模式,并且使用 UIInterfaceOrientationPortrait 调用此方法。但是,当我旋转设备时,不仅会为此方向调用此方法。

4

1 回答 1

0

shouldAutorotateToInterfaceOrientation通常只调用一次以告诉调用者应用程序将支持哪些方向(ORed 值或全部为 YES)。您可能希望willRotateToInterfaceOrientation:duration:在显示新方向之前检查方向和/或进行一些重新排列。

于 2012-08-09T13:04:21.267 回答