此錯誤是沒有意義的,爲擇優取向UIInterfaceOrientationLandscapeRight
由支撐定向preferredInterfaceOrientationForPresentation必須返回一個支持的接口方向
//iOS6
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
返回錯誤:
終止應用程序由於未捕獲的異常 'UIApplicationInvalidInterfaceOrientation',原因: 'preferredInterfaceOrientationForPresentation必須返回受支持的 接口方向!'
我發現這讓我很傷心!我有一個通用的應用程序共享viewcontroller代碼,並使用上述代碼測試用戶慣用語。 iPad必須只是風景,而且所有酒吧的肖像都需要風景。我無法在 – user7865437
處獲得正確的方向請注意,它是「UIInterfaceOrientationMaskLandscape」的「面具」部分,它是此答案的重要部分。原來的海報用戶在他的方法中使用了錯誤的枚舉。蘋果爲這種方法創建了一套新的enum/optionss似乎有點愚蠢,導致人們犯這個簡單的錯誤 - 另外Xcode甚至不提供任何編譯器時間檢查,因爲該方法返回NSUInteger。 –
@lms,我的整個應用程序只支持肖像模式,只有一個視圖(需要支持橫向)。在Plist中,我只爲肖像設置了方向,並且在上面的代碼中寫入了我想要改變風景方向的位置。但它給UIInterfaceOrientationLandscapeRight或UIInterfaceOrientationLandscapeLeft.But我想在我看來。你能告訴我如何得到它。 –