Question

I'm trying to create an overlay over the screen of one of my apps. Ideally, the overlay would receive tap gestures, while still allowing the user to interact with views under the overlay.

I know that views can be made "tap through" by setting their userInteractionEnabled property to NO. This allows the user to interact with views below the view in question:

self.overlay.userInteractionEnabled = NO;

However, I notice that this also seems to disable the tap gestures on the overlay view. I read somewhere that starting with iOS5 it is possible to pass touches between views. This makes me believe that it is possible to capture gestures on the overlay view, process them, and then pass them to the views below the overlay, creating the impression of the "tap through" overlay.

can someone point me in the direction of gesture recognizers sharing touches with views in iOS5, or an overlay-like controller like I'm describing?

If there's an alternative way of achieving what I'm describing, it would be good to know.

Thank you for any info!

Was it helpful?

Solution 2

I ended up just going through all of my container views, figuring out if the tap has happened within one of their frames, and dealing with that touch. It's not a very efficient solution, but it works.

for(UIView* container in self.view.subviews)
{

    location = [gestureRecognizer locationInView:container];

    frame = container.frame;
    location = [gestureRecognizer locationInView:container.dummyZoomView];
    foundTappableObject = CGRectContainsPoint(frame, location);
   //do whatever with the view which was tapped

 }

OTHER TIPS

Add the following to your gesture recognizer:

[recognizer setCancelsTouchesInView:NO]

"A Boolean value affecting whether touches are delivered to a view when a gesture is recognized."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top