MpMovieplayerController tap gesture recognizer doesn't trigger when in fullscreen

99封情书 提交于 2019-12-04 09:13:41

In my comment, I drafted how to get that covered when using proper fullscreen ([self.player setFullscreen:YES animated:NO];).

I would suggest that instead you simply resize the player view to cover the entire screen by setting its frame accordingly.

You initialising code would have to get rid of that player.fullscreen = YES;, but that I guess is obvious by now.

You can try this:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(willEnterFullScreen:)
                                             name:MPMoviePlayerWillEnterFullscreenNotification
                                           object:nil];

- (void)willEnterFullScreen:(NSNotification*)notification
{
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    UIView *aView = [[UIView alloc] initWithFrame:self.player.backgroundView.bounds];
    [aView addGestureRecognizer:tapGesture];
    [self.view.window addSubview:aView];
}

and then remove your subview when MPMoviePlayerWillExitFullscreenNotification is posted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!