2010-09-28 71 views
1

由于MPMoviePlayerViewController支持捏手势(两根手指分开)使电影播放器​​全屏,有没有什么方法可以消除这种手势?因为如果我使用手势,电影仍在播放没有视频。我认为电影控制器的观点是从超级观点中删除的。如何防止MPMoviePlayerViewController中捏合手势?

我试图压倒touchesBegan和通知WillEnterFullScreenNotification & DidEnterFullScreenNotfication,但它没有奏效。

回答

2

我有一个类似的问题与“捏手势”重新调整视频显示从风景到肖像。我通过访问MPMoviePlayerController对象的视图属性并将userInteractionEnabled设置为NO来解决此问题。

moviePlayer = [[MPMoviePlayerController alloc] init]; 
[moviePlayer view].userInteractionEnabled = NO; 

这防止任何用户触摸从通过获取和改变取向或MPMoviePlayerController的全屏状态。

+0

此代码还禁用视频控件。我已添加工作解决方案。 – Pion 2013-10-31 20:42:46

1

在我的情况下,jontron/curhipster接受的答案不起作用。

但是,当我将moviePlayers controlStyle设置为MPMovieScalingModeFill时,讨厌的捏被忽略。

我的代码:

NSString *filepath = [[NSBundle mainBundle] pathForResource:@"tutorial" ofType:@"mov"]; 
NSURL *fileURL = [NSURL fileURLWithPath:filepath]; 
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; 

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(moviePlaybackComplete:) 
              name:MPMoviePlayerPlaybackDidFinishNotification 
              object:self.moviePlayerController]; 

[self.view addSubview:self.moviePlayerController.view]; 
self.moviePlayerController.fullscreen = YES; 
self.moviePlayerController.scalingMode = MPMovieScalingModeFill; 
self.moviePlayerController.controlStyle = MPMovieControlStyleFullscreen; 
[self.moviePlayerController play]; 
1

这是正确的解决方案

[[[self.moviePlayer view] subviews] enumerateObjectsUsingBlock:^(id view, NSUInteger idx, BOOL *stop) { 
      [[view gestureRecognizers] enumerateObjectsUsingBlock:^(id pinch, NSUInteger idx, BOOL *stop) { 
       if([pinch isKindOfClass:[UIPinchGestureRecognizer class]]) { 
        [view removeGestureRecognizer:pinch]; 
       } 
      }]; 
     }];