我开始了一个示例项目并将以下代码添加到我的视图控制器中。启动后屏幕将是横向的。然后我去我的故事板,点击我唯一的视图,-> 编辑器-> 嵌入-> 导航控制器。再次启动程序:屏幕将是纵向的,无论我尝试什么都不会变成横向。这是为什么?(我的 plist 中启用了所有方向。)
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
@end