在我的应用程序中,我需要为我的 ViewControllers
处理不同的方向。
ViewController1
必须仅支持横向。ViewController2
必须支持横向 + 纵向。
我在 Summury 项目中启用了这样的所有方向:
因此,我将此代码插入 ViewController1
:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
然后我在 ViewController2
中插入这段代码:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
问题是 ViewController1
也在纵向旋转(它应该只支持横向)。
有什么想法吗?
非常感谢大家!
最佳答案
你的 viewController 是你的 rootViewController 吗? 如果不是,那可能是您的问题。
如果您的 rootViewController 是 UINavigationController,您应该知道它不会将这些消息转发到它的 topViewController。因此,如果这是您的情况,我建议您使用 UINavigationController 的子类,在其中覆盖这些新方法以转发到 topViewController。
关于ios - UIViewController 在 iPad 上处理方向 iOS 6.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12760457/