Repository navigation
Document how to avoid gesture recognizer conflicts - #7816
Conversation
Adding Gesture info as discussed: mapbox#2278 (comment) Not sure if using codeblocks is kosher.
| @note Adding your own gestures to MGLMapView will block the default gesture recognizer | ||
| built into MGLMapView. If you would like to use your own, you will need to implement | ||
| `gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:` in order to setup | ||
| which gesture takes precedence. For example, you could create your own UITapGestureRecognizer |
There was a problem hiding this comment.
Nit: surround MGLMapView and UITapGestureRecognizer in backticks.
|
|
||
| @note You are responsible for getting permission to use the map data and for | ||
| ensuring that your use adheres to the relevant terms of use. | ||
| @note Adding your own gestures to MGLMapView will block the default gesture recognizer |
There was a problem hiding this comment.
This doesn’t need to be a @note. Instead, place all this information above the existing @note so that it doesn’t get lumped into it.
| ensuring that your use adheres to the relevant terms of use. | ||
| @note Adding your own gestures to MGLMapView will block the default gesture recognizer | ||
| built into MGLMapView. If you would like to use your own, you will need to implement | ||
| `gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:` in order to setup |
There was a problem hiding this comment.
Qualify this method fully as -[UIGestureRecognizerDelegate gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]. Eventually jazzy will autolink Apple APIs like this one: realm/jazzy#13.
| ensuring that your use adheres to the relevant terms of use. | ||
| @note Adding your own gestures to MGLMapView will block the default gesture recognizer | ||
| built into MGLMapView. If you would like to use your own, you will need to implement | ||
| `gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:` in order to setup |
There was a problem hiding this comment.
Nit: replace “setup” (noun) with “set up” (verb phrase).
| that will be called only if the default MGLMapView tap fails by implementing the following:<br/> | ||
| ```swift | ||
| let mapTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(myCustomFunction)) | ||
| mapView.gestureRecognizers?.forEach { if($0 is UITapGestureRecognizer){mapTapGestureRecognizer.require(toFail: $0)} } |
There was a problem hiding this comment.
A standard for loop would be clearer than this call to forEach(_:), since this code isn’t using functional programming:
let mapTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(myCustomFunction))
for recognizer in mapView.gestureRecognizers! where recognizer is UITapGestureRecognizer {
mapTapGestureRecognizer.require(toFail: recognizer)
}(Also, note that although gestureRecognizers is optional, its documentation essentially eliminates the possibility of it being set to nil.)
| built into MGLMapView. If you would like to use your own, you will need to implement | ||
| `gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:` in order to setup | ||
| which gesture takes precedence. For example, you could create your own UITapGestureRecognizer | ||
| that will be called only if the default MGLMapView tap fails by implementing the following:<br/> |
There was a problem hiding this comment.
Once you take this additional content out of @note, this <br/> will be unnecessary, and you can replace it with a blank line.
Yes, we’re using code blocks elsewhere too, since jazzy does a great job with it. Technically |
| `UITapGestureRecognizer` that will be called only if the default MGLMapView tap gesture fails by | ||
| implementing the following: | ||
|
|
||
| ``` |
There was a problem hiding this comment.
The swift is still needed to let jazzy know to apply Swift syntax highlighting.
| built into `MGLMapView`. If you would like to use your own, you will need to implement | ||
| `-[UIGestureRecognizerDelegate gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]` | ||
| in order to set up which gesture takes precedence. For example, you could create your own | ||
| `UITapGestureRecognizer` that will be called only if the default MGLMapView tap gesture fails by |

Adding Gesture info as discussed: #2278 (comment)
Not sure if using codeblocks is kosher.