How to intercept touch events globally?

Posted by mystify on Stack Overflow See other posts from Stack Overflow or by mystify
Published on 2010-04-20T08:37:44Z Indexed on 2010/04/20 8:43 UTC
Read the original article Hit count: 209

Filed under:

I have an view which is sometimes covered by some other views. However, if the user slides the finger across the screen, I want to slide that underlying view across the screen, too.

I could start making custom views for all those covering subviews and forward all kinds of touch events, but that's somewhat cumbersome. Maybe there's some kind of notification or another way that a UIView or UIControl subclass can be aware of touch events happening right now, no matter where they are.

In short: I need an UIView subclass or UIControl subclass which knows about any touch events happening on the entire screen. Or at least if tht's not possible, knowing about any touch events happening above itself in the same underlying superview.

Another description: There are 20 views, all reside inside the same superview. The first view is covered by 19 others. But if the user slides across the screen, that first view must slide too, so it must be aware of touch events.

Is there any better solution that making all 19 views forward touch events? (yes, all 19 views respond to touch events in this example)

© Stack Overflow or respective owner

Related posts about iphone