2011-11-28 10 views
1

iPhoneをiOS 5.0にアップグレードするまで、私のコードは正常に動作していました。 MPMoviePlayerViewControllerは正常に動作していましたが、iOS 5.0では動作しませんので、iOs 5.0以降のバージョンではMPMoviePlayerControllerを使用する必要があります。それはうまく動作しますが、MPMoviePlayerViewControllerと同じようにMPMoviePlayerControllerは自動的に回転しません。iPhone:iOS 5.0でMPMoviePlayerControllerが回転しない

以下は私のコードです。誰も私にMPMoviePlayerControllerコードを自動的に回転させる方法を提案してもらえますか?

-(void)playVideo { 
NSString *filePath = [appDelegate filePath:@"startup.mp4"]; 

if(!appDelegate.iOS5) { 
    // This works perfectly till iOS 4 versions. Rotates automatically 
    MPMoviePlayerViewController *videoController = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:filePath]] autorelease]; 
    [self presentMoviePlayerViewControllerAnimated:videoController]; 
} else { 
    // This doesn't rotate automatically 
    NSURL *url = [NSURL fileURLWithPath:filePath]; 
    MPMoviePlayerController* moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:url] autorelease]; 

    moviePlayer.controlStyle = MPMovieControlStyleDefault; 
    moviePlayer.shouldAutoplay = YES; 
    [self.view addSubview:moviePlayer.view]; 
    [moviePlayer setFullscreen:YES animated:YES]; 
} 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return YES; 
} 

答えて

0

MPMoviePlayerControllerをサブクラス化し、向きをポートレートのみに強制してください。

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 

     return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

しかし、私はそれがうまくいくはずだと思います。

+0

他に何かがあるはずです。私はMPMoviePlayerViewController(iOS4.0以前)をMPMoviePlayerController(iOS5以降)を回転させているのはなぜだろうか? – applefreak

+0

こんにちはAppleDevelop、私も同じprobに直面しています私の場合は、NavControllerをNavControllerに配置し、ビデオがフルスクリーンモードではDidRotateが呼び出されていないので、メソッドが通常モードで呼び出されています。あなたは私を助けてくれるでしょう... – Dinakar

+0

いいえバディ。動いていない!あなたはそれを手に入れましたか? – applefreak

関連する問題