2015-04-14 78 views
7

我的應用程序和iOS 8.3有一個很大的問題。 我有總是相同的錯誤許多崩潰:iOS 8.3支持的方向崩潰

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [... shouldAutorotate] is returning YES

當「......」是很多類。 一個特殊的問題是類UIAlertView,我有同樣的問題UIAlertView crashs in iOS 8.3 但我無法解決UIAlertView的子類(蘋果說,UIAlertView類的目的是按原樣使用,不支持子類)或使用UIAlertController。 你能幫我嗎?

+0

「支持的方向與應用程序中沒有共同的方向」出現了我,當FE應用程序不支持橫向但UIViewController中返回YES景觀 – Injectios

+0

我們不能幫你沒有代碼,看看你是如何繼承UIAlertView中。 –

+0

Apple說UIAlertView類是按原樣使用,不支持子類,我不能繼承UIAlertView,所以我不能向你展示任何東西 – Anna565

回答

0

我解決了這個問題,這一點:

if objc_getClass("UIAlertController") != nil { 

    println("UIAlertController can be instantiated") 

    //make and use a UIAlertController iOS8 

} 
else { 

    println("UIAlertController can NOT be instantiated") 

    //make and use a UIAlertView iOS7 
} 

然後你可以保持您的應用程序運行在iOS的7和iOS 8

6

很多其他的應用程序沒有與崩潰這個bug,所以我想知道在我們的應用程序中是否有其他東西可以解釋這次崩潰。我確信iOS 8會得到UIAlertController,所以它不會崩潰,但對第三方框架沒有幫助。

在我們團隊的另一個工程師最終做這個固定:

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
    // This used to be: 
    //return UIInterfaceOrientationPortrait; 
} 
+2

謝謝你的這個答案!我有完全相同的問題。 –

1

這裏嘗試的解決方案後,他們沒有爲我工作。我在應用程序中支持iOS 6-8,而且,更重要的是,使用一些在內部使用UIAlertView的庫,所以只需有條件地編譯以在可用時不使用UIAlertController。

我想出了一個解決方案,爲我解決了這個問題。你的旅費可能會改變。我將頭文件包含在Header Prefix文件中,以確保它顯示在UIAlertView的任何位置。

我在這裏發佈這個任何人誰在這個問題上磕磕絆絆,並找到網絡周圍的解決方案無法正常工作。希望它有幫助。

https://gist.github.com/joshhudnall/cdc89b61d0a545c85d1d