我創建了一個「單一視圖應用程序」項目並將所有選項設置爲啓動並僅支持橫向。但該應用程序以縱向方向啓動窗口。如何使通用Xcode 5應用項目在橫向方向上啓動?
控制檯輸出說application:didFinishLaunchingWithOptions:
之後的窗口是:
{{0, 0}, {768, 1024}}
我增加了一個標準的系統按鈕來查看視圖控制器來說明該應用程序是橫向和縱向沒有,但該窗口是肖像。
由於堆棧溢出白色背景彩色我在Photoshop中右側的灰色,所以你可以看到它:
在application:didFinishLaunchingWithOptions:
我彩色的窗口紅色。這顯然不是在橫向方向。
我已經嘗試了所有的招數,我知道:
1)的Info.plist包含UISupportedInterfaceOrientations鍵搭配: UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight
2)的Info.plist包含UISupportedInterfaceOrientations〜ipad的關鍵有: UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight
3)Info.plist包含初始界面方向的UIInterfaceOrientation鍵: UIIn terfaceOrientationLandscapeRight
4)點擊了Xcode中的項目,然後選中所有人像選項,只檢查了景觀選項:
5)AppDelegate中和ViewController中都有:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
6)AppDelegate有:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
Xcode創建了兩個故事板文件。我現在只在iPad上測試。一個是Main_iPad.storyboard,它顯示了一個縱向的視圖控制器。但它只是一個模擬的接口指標。改變爲風景,並如預期沒有效果。
在應用程序啓動我檢查UIScreen界限,它也顯然是縱向,而不是橫向:
CGRect screenBounds = [[UIScreen mainScreen] bounds]; // {{0, 0}, {768, 1024}}
我怎樣才能使它在景觀推出,開創橫向窗口?