[英]View controller doesn't autorotate to portrait upside down
I have implemented a view controller just for autorotation. 我已经实现了一个只用于自动旋转的视图控制器。 So this view controller, which I called
RotatableViewController
, implements these methods: 所以这个视图控制器,我称之为
RotatableViewController
,实现了这些方法:
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (BOOL) shouldAutorotate {
return YES;
}
It should autorotate to all orientations, I also have checked the supported interface orientations in my target: 它应该自动旋转到所有方向,我还检查了目标中支持的接口方向:
But incredibly it doesn't autorotate in the portait upside down orientation: 但令人难以置信的是,它并没有在镜头中颠倒过来自动旋转:
What could be the problem? 可能是什么问题呢?
PS With iOS 6.1 , the view controller is instantiated through a storyboard. PS使用iOS 6.1,视图控制器通过故事板进行实例化。
The problem is that you're using a UINavigationController
, which does not support up side down by default on iPhones. 问题是你正在使用
UINavigationController
,默认情况下它不支持iPhone上下侧。 As a general design principle, iPhone apps should not support upside-down (allegedly because the "lock" switch does lock landscape mode on the iPhone, unlike on the iPad). 作为一般设计原则,iPhone应用程序不应该支持颠倒(据称因为“锁定”开关确实锁定iPhone上的横向模式,与iPad不同)。 The upside-down orientation is designed for iPad devices only.
倒置方向仅适用于iPad设备。
You could solve your problem by subclassing UINavigationController
and use a supportedInterfaceOrientations
that returns UIInterfaceOrientationMaskAll
and specify that as the base class for your navigation controller in the storyboard. 您可以通过
UINavigationController
来解决您的问题,并使用supportedInterfaceOrientations
返回UIInterfaceOrientationMaskAll
并将其指定为故事板中导航控制器的基类。 But I don't you should be doing that because apps on iPhone should generally not support upside-down portrait orientation. 但我不应该这样做因为iPhone上的应用程序通常不支持颠倒的纵向方向。
Older versions had the problem with UIInterfaceOrientationMaskAll. 较旧的版本存在UIInterfaceOrientationMaskAll的问题。 Not sure which version you are using.
不确定您使用的是哪个版本。 Try redoing with all the orientations.
尝试重做所有方向。
- (NSUInteger) supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.