【问题标题】:MPMoviePlayerController : orientation problemMPMoviePlayerController:方向问题
【发布时间】:2011-09-28 09:58:34
【问题描述】:

最后我必须在这里发布我的问题。是的,这可能是重复的问题,因为我已经提到了很多关于这个问题的答案。但我找不到任何解决方法。 (也没有发现任何关于标签栏应用程序特定的问题......)而且我不想使用 MPMoviePlayerViewController

我有标签栏应用程序。在最后一个选项卡的 VC 中有一个按钮。点击事件我想启动电影播放器​​。为此,我使用MPMoviePlayerController。当方向为 Portrait 时,一切都很好。但是关于变化,现在我只能在横向模式下播放它。

这是我的代码:

-(void)playMovie
{
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
    [self.scrollView addSubview:moviePlayer.view];

    [moviePlayer play];
    [moviePlayer setFullscreen:TRUE];
}
-(void)btnPlayHandler:(id)sender
{   
    NSLog(@"btnPlayHandler");

    NSURL * videoUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[dictResponse valueForKey:@"VideoPath"]]];
    moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:videoUrl];
    //[moviePlayer.view setFrame:CGRectMake(20, 40, 280, 222)]; 
    moviePlayer.fullscreen = YES ;
    moviePlayer.shouldAutoplay = NO ;

    [self performSelector:@selector(playMovie) withObject:nil afterDelay:1];    
}

- (void) movieWillExit:(NSNotification *)notification
{
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}

- (void) movieExit:(NSNotification *)notification
{
    [moviePlayer stop];
    [moviePlayer.view removeFromSuperview];
    moviePlayer = nil ;

    [btnPlay setHidden:FALSE];
}

- (void)moviePreLoad:(NSNotification *)notification  
{
    NSLog(@"moviePreLoad");
}

- (void)moviePlaybackComplete:(NSNotification *)notification  
{  
    NSLog(@"moviePlaybackComplete");
    [btnPlay setHidden:FALSE];
} 

只有设备的方向改变了,玩家的视图没有改变!如何做到这一点???是因为标签栏应用吗?

【问题讨论】:

  • 嗯!复杂的问题。 :) 我试图解决,但我不能。我会努力的 - 但稍后会。
  • 感谢回复...我尝试了您的解决方案,但它崩溃了...我只想更改播放器的方向...我认为默认是横向但在我的情况下它的纵向我认为是由于标签栏应用程序。我不明白该怎么办......

标签: iphone uiviewcontroller mpmovieplayercontroller


【解决方案1】:

您正在制作窗口横向,但是由于您在滚动视图中设置了 MPMoviePlayer 视图,因此它没有旋转。尝试根据您的方向旋转滚动视图。 请参阅此链接http://blog.sallarp.com/shouldautorotatetointerfaceorientation/。希望它能解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多