How to get touch/click on a MPMoviePlayerControlle

2019-05-03 23:12发布

问题:

In one of my application, I don't want to show any video controllers. But I need to get the touch on the media player view. I need to do some other action on touch on the movie player. How can I implement that. Please help

Thanks in advance.

回答1:

You can always attach a UITapGestureRecognizer to the view and handle the taps.

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[moviePlayer.view addGestureRecognizer:tap];
[tap release];

And handle the tap in handleTap:

- (void)handleTap:(UITapGestureRecognizer *)gesture {
    // Do some other action as intended.
}

Of course this works only on iOS 3.2 and later.



回答2:

You can also use this delegate method of UIGestureRecognizer.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;