Move gesture recognizers from GLKView to TGMapView itself #2127
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's different?
The gesture recognizers used in
TGMapView
used to be attached to theGLKView
that gets created as a subview. They are now attached to theTGMapView
itself. There should be no differences in behavior from this change.Why?
If the app is still in the background during initial setup of TGMapView, the GLKView will be nil when we try to attach gesture recognizers to it - leaving us with no working gestures.
To avoid this, we can instead attach the recognizers to the TGMapView itself.
This situation seems to occur in apps using the "scene" based UI framework introduced in iOS 13 (https://developer.apple.com/documentation/uikit/app_and_environment/scenes). This is the default UI paradigm in iOS going forward, so Tangram should work correctly within it.
Why was it done differently before?
I think when this was implemented the first time, I misunderstood how touch events are handled in iOS view hierarchies. I probably thought that the gesture recognizers had to be on the front-most view to receive touch events, but in fact they'll receive any touch events that aren't handled by subviews (https://developer.apple.com/documentation/uikit/touches_presses_and_gestures/using_responders_and_the_responder_chain_to_handle_events).