This is my code:
_mediaPlayer = [[MPMoviePlayerController alloc] init]; _mediaPlayer.controlStyle = MPMovieControlStyleNone; _mediaPlayer.shouldAutoplay = NO; [_mediaPlayer.view setFrame: CGRectMake(5, 5, 600,400)]; [playerHolder addSubview: _mediaPlayer.view]; // [self prepareScreenContentToPlay]; // UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleRollTap:)]; singleFingerTap.numberOfTapsRequired = 1; [_mediaPlayer.view addGestureRecognizer:singleFingerTap]; [singleFingerTap release];
And action method for gesture recognizer:
-(void)handleRollTap:(UITapGestureRecognizer*)sender{ NSLog(@"%@", @"touch"); }
MPMoviePlayerController works fine. In addition I want to handle touch on MPMoviePlayerController view but handleRollTap
never called. Why MPMoviePlayerController's view not works with UITapGestureRecognizer?
OK. If singleFingerTap.numberOfTapsRequired = 2;
then all works fine as well. But nothing for single tap..
Actually, answer to this is simple:
e.g.
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture)]; tapGestureRecognizer.delegate = self;
and somewhere else in the code:
#pragma mark - gesture delegate // this allows you to dispatch touches - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { return YES; } // this enables you to handle multiple recognizers on single view - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With