【发布时间】:2011-11-30 19:44:22
【问题描述】:
我知道我必须添加这个
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
到视图控制器,以便在横向模式下使特定的屏幕锁定,但是我必须为每个视图控制器执行此操作吗?有没有办法只做一个适用于所有视图控制器的主锁?
【问题讨论】:
-
如果你有一个包含一堆子视图/视图控制器的主视图控制器,那么你应该能够在那里完成它,它将影响所有的子视图。跨度>
-
我实际上没有那个,虽然我希望我有,但我只是通过 navController 推动 viewControllers :/
-
UINavigationController 扩展了 UIViewController,因此,您应该扩展 UINavigationController 并按照 Abhi 的建议实现
shouldAutorotateToInterfaceOrientation:。然后将该类用于您的 navController。
标签: objective-c ios cocoa-touch uiviewcontroller device-orientation