Capture touch events on UIView used as an overlay for a map view

6984
3
03-15-2012 09:26 PM
RobertLee
New Contributor
I am looking for a way to enable a UIVIew to take control of touch events while it is active above a map view. The UIView passes touches through to the window after I enabled the touches methods on the view controller. The map view also takes touches on exposed areas of the map not covered by this UIView.

Short of writing a category to extend the AGSMapview, I have tried forwarding the touch events from the main view of the view controller, which does capture the touch event, but does not successfully forward it.

What approach would you suggest?
0 Kudos
3 Replies
Nicholas-Furness
Esri Regular Contributor
Hi Robert,

I'm not entirely sure I understand what you're asking, so please set me straight if I've got it wrong, but I think you want to have a UIView displayed above the AGSMapView and you want it active (i.e. the user can interact with it) only some of the time?

Take a look at this post. You could set the userInteractionEnabled property of the UIView displayed above the map to control whether it traps UI events or not. Set it to NO and the events pass right on through to the map.

Again, apologies if I've misunderstood. Let me know.

Cheers,

Nick.
0 Kudos
RobertLee
New Contributor
Hi Robert,

I'm not entirely sure I understand what you're asking, so please set me straight if I've got it wrong, but I think you want to have a UIView displayed above the AGSMapView and you want it active (i.e. the user can interact with it) only some of the time?

Take a look at this post. You could set the userInteractionEnabled property of the UIView displayed above the map to control whether it traps UI events or not. Set it to NO and the events pass right on through to the map.

Again, apologies if I've misunderstood. Let me know.

Cheers,

Nick.


Nick,

That post and solution seems to address ignoring the touch events on the overlay, not the capture of them.

For my testing I placed the UIView above the map view allowing some of the map to be exposed. When I touch inside the UIView I get an acknowledgement of the touch from the underlying view of the view controller (I placed an NSLog at that level to acknowledge the event), but the map does not respond, but neither does the UIView. When I move over to the map view I get complete interaction as expected.

This overlay class in a standalone view controller works as as expected. My view hierarchy is as follows:

overlay UIView - custom UIView class

AGSMapview - standard map view class

view controller UIView - customer UIViewController class.

I need to toggle the overlay in and out of view and touch interaction. The User Interaction Enabled is set for the overlay field and toggling the hidden status of the view removes it from the touch hierarchy as expected.

I hope this clears things up.

Rob
0 Kudos
Nicholas-Furness
Esri Regular Contributor
Hey Rob,

I *think* I see what you're saying now, but if so I don't see what could be going wrong so it may be time to look at some code.

Could you attach a project here for me to look at, PM me or send me an email (use my forum ID at esri.com)?

Cheers,

Nick.
0 Kudos