【发布时间】:2014-07-23 09:51:18
【问题描述】:
我已经尝试这样做了 2 周,只是发现它不起作用的原因:
已弃用的 API
以下 API 已弃用:
界面方向的 UIViewController 方法和属性。如Unified Storyboards for Universal Apps 中所述,特征和大小类替换它们。
我需要的是:FirstViewController,即rootViewController 到我的navigationController。 FristViewController 应该仅在纵向模式下可用(永远不会在横向模式下显示)。
然后导航堆栈中有一些中间 ViewControllers(支持两个方向),直到我到达 LastViewController,它应该仅在 LandscapeRight 模式下可用(永远不会在肖像或其他模式)。
我一直在尝试使用以下 CustomNavigationController,但显然 iOS8 中的情况发生了变化,我无法让它工作:
- (BOOL)shouldAutorotate { // Available in iOS 6.0 and later
return YES; // // May use topViewController's, but in this app it always returns YES
}
- (NSUInteger)supportedInterfaceOrientations { // Available in iOS 6.0 and later
if (self.topViewController != nil)
return [self.topViewController supportedInterfaceOrientations];
else
return [super supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { // Available in iOS 6.0 and later
if (self.topViewController != nil)
return [self.topViewController preferredInterfaceOrientationForPresentation];
else
return [super preferredInterfaceOrientationForPresentation];
}
谢谢!
【问题讨论】:
-
我将标题从设备方向更改为界面方向 - 设备方向包括您不关心的“面朝上”和“面朝下”等内容
-
感谢您的编辑/评论! :)
标签: iphone objective-c xcode ios8