Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Document how to avoid gesture recognizer conflicts - #7816

Merged
1ec5 merged 5 commits into
mapbox:release-ios-v3.4.0from
nitrag:nitrag-docs-gestures
Jan 23, 2017
Merged

1ec5 merged 5 commits into
mapbox:release-ios-v3.4.0from
nitrag:nitrag-docs-gestures

Conversation

@nitrag

@nitrag nitrag commented Jan 23, 2017

Copy link
Copy Markdown
Contributor

Adding Gesture info as discussed: #2278 (comment)

Not sure if using codeblocks is kosher.

Adding Gesture info as discussed: mapbox#2278 (comment)

Not sure if using codeblocks is kosher.
@nitrag

nitrag commented Jan 23, 2017

Copy link
Copy Markdown
Contributor Author

@1ec5

Comment thread platform/ios/src/MGLMapView.h Outdated
@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: surround MGLMapView and UITapGestureRecognizer in backticks.

Comment thread platform/ios/src/MGLMapView.h Outdated

@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread platform/ios/src/MGLMapView.h Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualify this method fully as -[UIGestureRecognizerDelegate gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]. Eventually jazzy will autolink Apple APIs like this one: realm/jazzy#13.

Comment thread platform/ios/src/MGLMapView.h Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: replace “setup” (noun) with “set up” (verb phrase).

Comment thread platform/ios/src/MGLMapView.h Outdated
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)} }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Comment thread platform/ios/src/MGLMapView.h Outdated
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/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you take this additional content out of @note, this <br/> will be unnecessary, and you can replace it with a blank line.

@1ec5 1ec5 added this to the ios-v3.4.1 milestone Jan 23, 2017
@1ec5 1ec5 added documentation iOS Mapbox Maps SDK for iOS labels Jan 23, 2017
@1ec5

1ec5 commented Jan 23, 2017

Copy link
Copy Markdown
Contributor

Not sure if using codeblocks is kosher.

Yes, we’re using code blocks elsewhere too, since jazzy does a great job with it. Technically @pre would be more compatible with Quick Help, but Quick Help is quite broken for Objective-C and the backticks let us specify a syntax highlighting language.

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! Here’s what it currently looks like, by the way:

MGLMapView

Comment thread platform/ios/src/MGLMapView.h Outdated
`UITapGestureRecognizer` that will be called only if the default MGLMapView tap gesture fails by
implementing the following:

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The swift is still needed to let jazzy know to apply Swift syntax highlighting.

Comment thread platform/ios/src/MGLMapView.h Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missed an MGLMapView.

@1ec5 1ec5 self-assigned this Jan 23, 2017
@1ec5 1ec5 added the macOS Mapbox Maps SDK for macOS label Jan 23, 2017
@1ec5 1ec5 changed the title Docs: Expound gesture implementation (iOS) Document how to avoid gesture recognizer conflicts Jan 23, 2017
@1ec5
1ec5 merged commit 0c95fcf into mapbox:release-ios-v3.4.0 Jan 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

documentation iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants