2015-02-05 167 views
0
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    NSUInteger orientations = UIInterfaceOrientationMaskPortrait; 
    if (self.fullScreenVideoIsPlaying == YES) 
    { 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
    } 
    else 
    { 
     if(self.window.rootViewController) 
     { 
      UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject]; 
      orientations = [presentedViewController supportedInterfaceOrientations]; 
     } 
     return orientations; 
    } 
} 

我試圖改變屏幕的方向只有一個頁面,我當我啓動程序添加此功能,程序無法啓動,給這個錯誤初始屏幕 錯誤:的iOS AppDelegate中添加supportedInterfaceOrientationsForWindow

2015-02-06 00:40:24.264 AppName[5002:1189245] -[SplashScreen viewControllers]: unrecognized selector sent to instance 0x14d510010 
2015-02-06 00:40:24.266 AppName[5002:1189245] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SplashScreen viewControllers]: unrecognized selector sent to instance 0x14d510010' 
*** First throw call stack: 
(0x18269659c 0x192da00e4 0x18269d664 0x18269a418 0x18259eb6c 0x100098614 0x186ebc594 0x186ebc210 0x186ec548c 0x186ec4ee0 0x186ebc154 0x1870d45f0 0x1870d362c 0x1870d1dec 0x18a90d62c 0x18264ea28 0x18264db30 0x18264bd30 0x1825790a4 0x186eb33c8 0x186eae3c0 0x100102560 0x19340ea08) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

任何想法??我該如何解決這個問題?

回答

1

也許你想改變viewControllerschildViewControllers

編輯1:對不起,我現在才發現,你認爲你的rootViewControllerUINavigationViewController

這顯然不是你可以從錯誤信息中看到的。它是類的SplashScreen

編輯2:我建議你做以下,並從那裏

if(self.window.rootViewController && [self.window.rootViewController isKindOfClass:[UINavigationViewController class]]) 
{ 
     UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject]; 
     orientations = [presentedViewController supportedInterfaceOrientations]; 
} 

return orientations; 
+0

謝謝你這段代碼部分工作:)) – 2015-02-05 23:01:29

相關問題