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

发布于 2024-09-25 08:50:33 字数 282 浏览 2 评论 0原文

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

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

As MPMoviePlayerViewController supports pinch gesture ( two fingers move apart ) to make the movie player full screen, is there any method to remove this gesture? Because if I use the gesture, the movie is still playing without the video. I think the view of movie controller is removed from super view.

I tried overriding touchesBegan and the notification WillEnterFullScreenNotification & DidEnterFullScreenNotfication, but it didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

关于从前 2024-10-02 08:50:33

我在将视频显示从横向重新定向为纵向时遇到了类似的问题。我通过访问 MPMoviePlayerController 对象的 view 属性并将 userInteractionEnabled 设置为 NO 解决了这个问题。

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

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

I had a similar issue with the "pinch gesture" reorienting the video display from landscape to portrait. I solved it by accessing the view property of the MPMoviePlayerController object and setting userInteractionEnabled to NO.

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

This prevents any user touches from getting through and changing the orientation or fullscreen status of the MPMoviePlayerController.

善良天后 2024-10-02 08:50:33

就我而言, 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];

In my case the accepted answer from jontron/curhipster didn't work.

But when I set the moviePlayers controlStyle to MPMovieScalingModeFill the pesky pinch was ignored.

My code:

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];
咋地 2024-10-02 08:50:33

这是正确的解决方案

[[[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];
                }
           }];
      }];

This is the correct solution

[[[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];
                }
           }];
      }];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文