正如标题所述,我的应用程序 atm 中的方向存在很大问题。在不同的幻灯片中,我似乎根本无法控制方向。以下内容我已经尝试过并且在我的应用程序中有效/无效:
Xcode 拒绝在任何幻灯片上听取 shouldAutorotateToInterfaceOrientation 方法中给出的任何代码。
Xcode 拒绝听取每张幻灯片的 stoaryboad 中给出的任何设置。
Xcode 监听 info-plist 文件,但您只能通过该文件为应用中的所有 View /幻灯片设置方向。我想要一些幻灯片允许横向模式,而其他幻灯片只允许纵向模式。
我试图删除我的应用程序中的所有 UINavigationBars/Tabbars,实际上只使用 1 个 ViewController 作为初始 ViewController,问题仍然存在,只能从 info-plist 文件管理方向。基本上,除了调整方向设置的 info-plist 文件之外,应用程序会拒绝收听任何其他内容吗?
我已尽最大努力理解这个问题,但我不能说到目前为止我获得了更大的“顿悟时刻”,因为苹果提供的所有可能的调整设置的方法至少在我的应用程序中根本不起作用,伟大的苹果!。 ...我们有没有其他人以前遇到过这个问题或以前听说过这个问题?
最佳答案
- (BOOL)shouldAutorotateToInterfaceOrientation:
在 iOS 6 中已弃用。
您应该覆盖 UIViewController 子类的 - (NSUInteger)supportedInterfaceOrientations
方法。
例子:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;
}
编辑:
如果您使用的是 UINavigationController,您也必须对其进行子类化,并实现上述逻辑。这是预期的功能。相关 StackOverflow 问答:
iOS 6 bug: supportedInterfaceOrientations not called when nav controller used as window root
iOS 6 rotations: supportedInterfaceOrientations doesn´t work?
Set different supportedInterfaceOrientations for different UIViewControllers
关于iphone - IOS 设置方向不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13165601/