Search code examples
iosuiviewuiscrollviewuitapgesturerecognizer

UIScrollView detect tap


I've got a UIScrollView in which I need to be able to scroll. At the same time, I need to detect taps on the scrollview. How can I achieve that?

I've already tried adding a TapGestureRecognizer to the view without any luck. Also tried several approaches using the UIScrollViewDelegate methods.

There is MPMoviePlayerController view inside the UIScrollView.

I used the following code adding the reconigzer

UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)] autorelease];
singleTap.enabled = YES;
singleTap.cancelsTouchesInView = NO;

[scrollView addGestureRecognizer:singleTap];

Thanks.


Solution

  • Solution: When adding a MPMoviePlayerController's view to a UIScrollView one need to disable the userinteraction on the MpMoviePlayerController's view in order for the UIScrollView to be able to catch a gesture recognizer. This solution ofc only works when you do not want the interaction using mpmovieplayercontrollers default menus etc.