【问题标题】:Flipping a Video Horizontally in Xcode在 Xcode 中水平翻转视频
【发布时间】:2012-09-10 23:46:31
【问题描述】:

我有一个视频,当我以全视图播放并水平翻转模拟器时,视频不会翻转。如何根据 iPhone 的加速度计让视频翻转?

如果有帮助,这里是视频的代码:

- (void)viewDidAppear:(BOOL)animated {

    NSBundle *bundle=[NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"MainPageMovie" ofType:@"mp4"];
    NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    theMovie.scalingMode = MPMovieScalingModeAspectFill;
    theMovie.view.frame = CGRectMake(115.0, 156.0, 200.0, 150.0);
    [self.view addSubview:theMovie.view];
    [theMovie play];

    [super viewDidLoad];
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
}

【问题讨论】:

    标签: iphone ios ios-simulator


    【解决方案1】:

    您的 MPMoviePlayerController 视图作为子视图添加到另一个视图控制器的视图中。在那个父视图控制器中,您是否重写了 shouldAutorotateToInterfaceOrientation 方法? 如果您只是在寻找横向(水平)旋转,您可以将代码如下:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Overriden to allow any orientation.
        return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
    }
    

    【讨论】:

    • return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    • Vera 不,此应用程序是原始应用程序,我没有为任何视图添加旋转。所有视图都是垂直的。我只想在全视图时旋转视频。这个可以吗??
    • 视频的问题已解决 :) 我刚刚在代码中添加了(返回 YES;)。但现在的问题是,当我旋转模拟器时,所有其他视图都会旋转。我没有为其他视图添加横向视图。如何只允许视频旋转?
    • 编辑:除了我添加了旋转代码的视图(视频所在的视图)之外,其他视图都没有旋转。我现在的问题是,如何只允许在全屏视图下旋转视频?
    【解决方案2】:

    为了旋转较大视图控制器视图的特定子视图(在您的情况下,仅旋转视频就是这种情况),您必须执行CGAffineTransforms。这将允许您调整视图大小、旋转它等。AFAIK,这可能是旋转单个视图的最佳途径。

    但是,您可能需要对MPMoviePlayerViewController 进行更多研究。看看this post,好像解决了你的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-04
      • 2018-07-07
      • 2022-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-31
      相关资源
      最近更新 更多