這個問題應該是一個簡單的... 我已經搜索了很多關於它,我已經嘗試了我的項目上的所有設置。 事情是我正在一個不是我的項目上工作。從應用程序代理啓動的應用程序,然後我添加一個UIViewController
(沒有XIB文件)所有代碼完成。 ViewController實際上是在風景上,但事情是應用程序正在肖像上運行(當我拉動通知視圖時,它將像肖像模式下變成一樣)。如何在景觀中啓動應用程序? (沮喪)
這是在AppDelegate.m文件中實現:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationLandscapeRight;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskPortrait;
//if i am writing only the landscape right orientation the app crashes!
}
*終止應用程序由於未捕獲的異常「UIApplicationInvalidInterfaceOrientation」,理由是:「支持的方向與應用程序中沒有共同的方向,並shouldAutorotate正在恢復YES」 *第一擲調用堆棧: (0x3bfef2a3 0x35ede97f 0x3bfef1c5 0x3518988f 0x3532e579 0x3520dd3d 0x3520cfc7 0x3532f257 0xa5bc1 0x35188319 0x351a4f0f 0x351a4e97 0x3512aa33 0x3bfc46cd 0x3bfc29c1 0x3bfc2d17 0x3bf35ebd 0x3bf35d49 0x3a3032eb 0x351752f9 0x9803b 0x97fe0) libC++ abi.dylib:終止調用拋出異常
如果我用縱向模式編寫應用程序啓動。我還嘗試在info.plist
中添加行,並將關鍵字設置爲風景的初始界面方向值(右側主頁按鈕)。 也支持接口定位到lanscape。 非此變化的任何東西,我只是想知道我如何得到這種行爲,從風景模式獲得上述通知
任何人,謝謝!
首先感謝您的快速反應,但我沒有使用UINavigation控制器 –
OK,那麼你必須使用這個代碼,而無需UINavigation控制器,這是工作.. –
這是行不通的,應用程序仍然崩潰 –