我使用的是 iOS 6.0 beta,但我的旋转功能不再有效。
我在哪里可以设置 UINavigationControllers supportedOrientations?
根据这个http://news.yahoo.com/apple-ios-6-beta-3-changes-182849903.html UINavigation Controller 不会咨询他们的 child 来确定他们是否应该自动旋转。
我不再使用 shouldAutorotateToInterfaceOrientation:,因为它已被弃用。 相反,我使用 supportedInterfaceOrientations: 和 shouldAutoRotate: 并且它们工作正常,直到我将 ViewController 放入 NavigationController(作为子级)。 从那时起,ViewController 中指定的方向不再起作用。 它似乎正在使用导航 Controller (UIInterfaceOrientationMaskAllButUpsideDown) 设置的方向
如何为 NavigationController 设置 InterfaceOrientations,以便我的 ViewControllers 锁定为纵向方向?
我是否必须继承 UINavigationController 并在那里设置 InterfaceOrientations?在 iOS 6.0 中继承 UINavigationController 不是不好的做法吗?
谢谢你的帮助堆!
干杯!
最佳答案
如果你想让它再次咨询它的 child ,你可以向 UINavigationController 添加一个类别
@implementation UINavigationController (Rotation_IOS6)
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end
关于objective-c - 我在哪里可以设置 UINavigationControllers supportedOrientations?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12169517/