如何防止MPMoviePlayerViewController中的捏合手势?

时间:2010-09-28 09:58:38

标签: ios mpmovieplayercontroller multi-touch

由于MPMoviePlayerViewController支持捏合手势(两个手指分开)以使电影播放器​​全屏,是否有任何方法可以删除此手势?因为如果我使用手势,电影仍然没有视频播放。我认为电影控制器的视图已从超级视图中删除。

我尝试覆盖touchesBegan和通知WillEnterFullScreenNotification& DidEnterFullScreenNotfication,但它不起作用。

3 个答案:

答案 0 :(得分:2)

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

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

这可以防止任何用户触摸通过并更改MPMoviePlayerController的方向或全屏状态。

答案 1 :(得分: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];

答案 2 :(得分: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];
                }
           }];
      }];
相关问题