0

I have a view hierarchy that looks like this.

buttonsView <-- UIView with 1-3 small buttons MKMapView <-- bottom most view

When my buttonsView is shown I still want the user to be able to scroll the MKMapView if the user is NOT touching any of the buttons.

I have tried different combinations of userInteractionEnabled = NO but nothing helps.

jdog
  • 10,351
  • 29
  • 90
  • 165

2 Answers2

1

You have several ways to solve this:

  • The top view with the three small buttons can be much smaller, so that is only covers the area the three small buttons need. By this, the top view won't cover the map view, and you can still scroll it around.

  • Implement your own hitTest / pointInside functions to let the top view decide whether it wants to catch an event (when you tap on one of its buttons) or it decides to send the event further up the responder chain (when the user taps anything else). See for example here for possible ways to do it: Allowing interaction with a UIView under another UIView

Community
  • 1
  • 1
TheEye
  • 9,280
  • 2
  • 42
  • 58
0

The view on the front takes all the interactions. No matter if it is transparent or not. You should pass the gestures to the MKMapView in the bottom. Another approach is to resize the view with the buttons to not cover the whole MKMapView, but only the part with the buttons. In that way, the user will be able to scroll only in the area where there are no buttons.