3

アプリケーションで MPMoviePlayerController を使用してビデオを再生しています。私のアプリケーションは縦向きモードでしか動作しません。アプリケーションのビデオを横向きモードでのみ再生する必要があります。だから、誰でも私がこれを行う方法を提案してください。現在、私のビデオはポートレート モードで再生されています。

4

2 に答える 2

3

これを行うには、クラスをサブクラス化する必要がありますMPMoviePlayerController

@interface yourMovie:MPMoviePlayerController
{
}
@end

shouldAutoRotate実装でメソッドを実装し、ランドスケープモードのみを返す必要があります

@implementation yourMovie

- (BOOL)shouldAutorotate
{
    return [[UIDevice currentDevice] orientation] != UIInterfaceOrientationPortrait;
}
@end

yourMovieそして、代わりにインスタンスを作成する必要がありますMPMoviePlayerController

于 2012-10-22T12:18:15.287 に答える
2

MPMoviePlayerController でこのコードを使用します。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft];
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

代わりにUIInterfaceOrientationLandscapeLeft使用することもできますUIInterfaceOrientationLandscapeRight...

于 2012-10-22T12:17:58.470 に答える