How to capture only one click / click on the MPMoviePlayerController view while the controls are hidden?

I previously asked how to capture any touch input in the MPMoviePlayerController view when MPMovieControlStyle is set to MPMovieControlStyleNone . It has been suggested that I can use UIGestureRecognizer for this.

I can capture double taps on the screen using a gesture recognizer this way, but not individual taps. The code I used for this is as follows:

///**********/// singleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleClickOnMediaView:)]; singleTapGestureRecognizer.numberOfTapsRequired = 1; [self.moviePlayer.view addGestureRecognizer:singleTapGestureRecognizer]; [singleTapGestureRecognizer release]; ///**********/// 

Why can't I capture individual taps in the MPMoviePlayerController view using this code? Is there anything special about how it handles individual cranes?

+4
source share
2 answers

I know this is a little old question, but here is the solution if someone needs it. In order to handle single and double taps in the same view, the write once recognizer must wait for the double tap recognizer to fail. Something like that:

 UITapGestureRecognizer* doubleTapRecon = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap)]; [doubleTapRecon setNumberOfTapsRequired:2]; [doubleTapRecon setDelegate:self]; [self.view addGestureRecognizer:doubleTapRecon]; UITapGestureRecognizer* singleTapRecon = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap)]; [singleTapRecon setNumberOfTapsRequired:1]; [singleTapRecon requireGestureRecognizerToFail:doubleTapRecon]; [singleTapRecon setDelegate:self]; [self.view addGestureRecognizer:singleTapRecon]; 

Please note that if you are not using ARC, you need to take care of memory management.

0
source

No answer above will work to get the only highlight gesture you have to implement "UITapGestureRecognizerDelegate" and use the method

 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } 

Because 'moviePlayer' also uses tap gestures, so in order to get started, we need our own unique Tap Only above method.

0
source

All Articles