在 iOS7 中你如何停止第一个视图控制器自动旋转? [英] in iOS7 how do you stop the First viewcontroller autorotating?
问题描述
我有一个应用程序只需要一个屏幕就可以自动旋转,第一个和最后一个屏幕应该是纵向的.我可以使用以下方法让最后一个屏幕停止旋转:
I have an app that just needs one screen to autorotate, the first and last screens should be portrait. I can get the last screen to stop rotating using:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
但这在第一个屏幕上不起作用,我正在使用带有 UINavigationController
的故事板(我认为这可能与它有关?)
But this does not work on the first screen, I am using a storyboard with a UINavigationController
(I'm thinking that may have something to do with it?)
如有任何帮助,我们将不胜感激.谢谢
Any help would be gratefully received. Thanks
推荐答案
您可能需要对 UINavigationController
进行子集化,您应该使用它而不是标准的 UINavigationController
.
you may need to subset the UINavigationController
and you should use it instead of the standard UINavigationController
.
我在我的项目中已经这样做了,所以这关心各个 UIViewController
类的自定义方向:
I have done this in my projects, so this cares of the individual UIViewController
classes' custom orientations:
#import <UIKit/UIKit.h>
@interface UIOrientationController : UINavigationController { }
@end
.m
@implementation UIOrientationController
- (BOOL)shouldAutorotate {
return [self.topViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.topViewController supportedInterfaceOrientations];
}
@end
注意:如果您的最终代码中需要它,您可以通过覆盖更多方法来扩展此类.
这篇关于在 iOS7 中你如何停止第一个视图控制器自动旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!