【发布时间】:2013-06-07 16:04:00
【问题描述】:
正如长标题所暗示的那样,我最近一直在为 IOS 6 Orientations 苦苦挣扎。 我正在处理一个仅基于 iPhone 的当前项目,几乎所有的视图控制器都只支持纵向(默认方向)。 我有这个视图控制器虽然我想给多个方向作为唯一的一个,独立的。我该如何正确地做到这一点?这是我的方法。干杯'
在设置中 - 选择除纵向底部向上之外的所有方向。
-
在我想给出多个方向的 Viewcontroller 中 - 嵌入了此代码
-(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } -(BOOL)shouldAutorotate { return YES; }
对于其余的视图控制器 - 支持一种方向(默认方向)纵向:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
-(BOOL)shouldAutorotate
{
return YES;
}
它不起作用。似乎没有调用方法 - 但项目和构建只是坚持设置中的选定方向。为什么这不起作用!
任何帮助将不胜感激。
【问题讨论】:
-
如果你想知道方法是否被调用然后
NSLog(@"whateverMethodWasCalled in myViewController") -
一点帮助都没有,你知道是否可以覆盖视图控制器中“设置”中设置的方向吗?
-
设置定义了您的应用支持的方向。您的视图控制器在supportedInterfaceOrientations 中说明了他们支持的内容。应用程序设置 (.plist) 和您在视图控制器的 supportedInterfaceOrientations 中定义的方向重叠的任何方向都是您的视图将自动旋转到的方向。
-
感谢@Unicorn 的回复,是的,我想知道我的 shouldautorotate & supportedInterfaceOrientations 中的方向方法是否被正确调用。
标签: ios xcode uiviewcontroller orientation