2010-09-28 70 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]; 
       } 
      }]; 
     }];