1

只是对如何在除一个视图之外的所有视图中禁用自动旋转有点困惑。我正在使用FGallery,我只想在该视图上启用旋转。

谁能告诉我如何进行?

4

2 回答 2

1

对于 iOS 5.x,您可以从 实现此方法UIViewController,仅返回YES您支持的方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

例如,仅支持纵向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
        return YES;
    }

    return NO;
}

请注意,此方法在 iOS 6 之后已弃用。

于 2012-12-28T16:10:19.497 回答
0

您是否在视图控制器中实现了 shouldAutorotateToInterfaceOrientation:interfaceOrientation 方法?

如果你对除了你想要的方向之外的所有东西都返回“否”,那应该会得到你想要的结果。

于 2012-12-28T16:10:36.597 回答