【问题标题】:Rotate MPMoviePlayerController to Landscape - iPhone SDK将 MPMoviePlayerController 旋转到横向 - iPhone SDK
【发布时间】:2010-09-13 01:15:30
【问题描述】:

我正在尝试将我的 MPMoviePlayerController 旋转到横向视图,但它始终处于纵向模式。我在 UIViewController 中执行此操作,当我处于全屏模式时,我仍然无法旋转我的 MPMoviePlayerController。我必须对 shouldAutorotatetoOrientation 方法做些什么吗?如果有人知道该怎么做,请回复!

谢谢,

凯文

【问题讨论】:

    标签: iphone objective-c mpmovieplayercontroller rotation landscape


    【解决方案1】:

    来自UIViewController class reference

    默认情况下,UIViewController 类仅以纵向模式显示视图。要支持其他方向,您必须重写 shouldAutorotateToInterfaceOrientation: 方法并为您的子类支持的任何方向返回 YES。如果您的视图的自动调整大小属性配置正确,那么您可能只需要这样做。但是,UIViewController 类为您提供了额外的钩子,以便您根据需要实现额外的行为。

    例如,如果您的autoresizingMask 设置为UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight,并且您的电影播放器​​视图的父视图具有autoresizesSubviews = YES,那么您只需从shouldAutorotateToInterfaceOrientation 返回“是”即可。

    【讨论】:

    • 谢谢,但我已经通过将视图调整为横向尺寸并旋转 MPMoviePlayerController 手动使其工作。但是现在我导致了当我启用 [moviePlayer setControlStyle:MPMovieControlStyleFullScreen]; 时我的完成按钮不起作用的问题;
    【解决方案2】:

    我发现这种方式只是有用,但设置所需的框架需要时间-

    theMovie=[[MPMoviePlayerController alloc] initWithContentURL:theURL]; 
    // Rotate the view for landscape playback   
    [[theMovie view] setBounds:CGRectMake(-230, 155, 480, 350)];
    [[theMovie view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 
    

    【讨论】:

      猜你喜欢
      • 2011-09-06
      • 2012-06-17
      • 2010-12-29
      • 1970-01-01
      • 1970-01-01
      • 2012-01-08
      • 2010-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多