我開始了一個示例項目,並將以下代碼添加到了我的視圖控制器中。發佈後,屏幕將呈現風景。 然後我去了我的故事板,點擊我唯一的視圖, - >編輯器 - >嵌入 - >導航控制器。再次啓動程序:屏幕將顯示爲縱向,無論我嘗試什麼,都不會改變爲橫向。這是爲什麼? (所有的方位都在我的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
你說得對。子類化後,我確實設法旋轉到風景,但如果我將添加' - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait;這個'ViewController'將是縱向的(而其他視圖控制器將在橫向啓動),所以說「這個視圖控制器(ViewController)的supportedInterfaceOrientations是不相關的」是一半正確的。我錯了嗎? – Segev 2013-04-30 18:40:56
'preferredInterfaceOrientationForPresentation'是無關緊要的。這不是「演示」情況。 – matt 2013-04-30 18:42:02
關於你的筆記。我正在討論視圖啓動的方向(不旋轉設備)。我還沒有完全致力於我的工作,但我會爲此另外提出一個問題。謝謝。 – Segev 2013-04-30 19:00:17