简体   繁体   中英

How to Enable Touch Events For a MapView underneath a UIView (iOS8/Swift)

This is a question that has been asked before however the solution does to appear to work as it used to, or there is another problem occurring.

I have a MapView, and on top of it I have placed an opaque UIView that acts as an indicator for the user. This has been done in the interface builder, so no manual placement of controls or anything like that. I want the UIView to NOT block user interactions with the MapView such as double-tap to zoom, pan, etc. I have tried the existing solution which is to uncheck the box "User Interaction Enabled" in the interface builder for the UIView, however that has not worked.

How can I solve this?

I will post code if it turns out that iOS8/XCode 6 does not effect this solution.

Code: https://github.com/ChrisChares/swift-alarm Github Repo, note that this is not my code, but it reflects the problem shown here. Goto the MapViewController interface.

How about overriding this UIView's hittest method, and returning nil? I can't test with ios8 sim at the moment, so that's just a guess.

SOLUTION: I figured it out, this could be a potential glitch in Xcode 6, or Apple has intentionally changed certain logic in the options panels.

Toggling the User Interaction Enabled box does not fix the problem as noted earlier.

However, doing this using code does, simply use:

targetView.userInteractionEnabled = false and you will notice the MapView properly registers the touches from the UIView.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM