0

私は、ポートレートである 1 つの方向のみを使用しているアプリに取り組んでいます。これはデバイスの向きの設定です:

ここに画像の説明を入力

しかし、私のアプリにはMPMoviePlayerViewController、Landscape Right モードでのみ表示したいビデオ プレーヤー (のカスタム プレーヤー) があり、回転させるべきではありません。これは正常に動作しています。つまり、このカスタム プレーヤーは完全に横向きで表示されUIAlertviewますが、アプリケーションを使用しているときに、このメソッドでクラッシュします。

- (BOOL)shouldAutorotate {


    return NO;

}

これらは、いくつかの他の向きの方法です:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight; // or Right of course
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
- (NSUInteger)supportedInterfaceOrientations
#else
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
#endif
{
    return UIInterfaceOrientationMaskLandscape;
}

このエラーが発生しています:

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

3 に答える 3

-1

解決策 1. info.plist に移動し、必要のない他の向きを削除します:-

ここに画像の説明を入力 解決策 2. 次のコードを使用します (あなたの場所):-

-(NSUInteger)supportedInterfaceOrientations {
    UIViewController *vC = self.topViewController;
    return vC.supportedInterfaceOrientations;
}

-(BOOL)shouldAutorotate {
   UIViewController *vC = self.topViewController;
   return [vC shouldAutorotate];
}
于 2016-05-27T10:10:20.443 に答える