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

[ios] Always show annotation view even when view reuse is not used #6485

Merged
merged 2 commits into from
Sep 27, 2016

Conversation

boundsj
Copy link
Contributor

@boundsj boundsj commented Sep 27, 2016

This fixes an issue noted in #6458 (comment) where the map view would drop annotation views
if the developer did not make full use of the reuse queue.

The fixes are:

  • Guard against enqueuing a view for reuse if it does not have a viewReuseIdentifier. Previously, if the app developer created a new annotation view with no reuse id each time [MGLMapViewDelegate mapView:viewForAnnotation:] was called and then the view was scrolled offscreen, we attempted to add the view to the reuse queue (for no good reason) and did not update the views center ever again. This change avoids the reuse queue and just updates the
    center always.
  • Add any annotation view that should be displayed but is not in the annotation container view to the annotation container view. Previously, if the app developer created a new annotation view with a reuse id each time [MGLMapViewDelegate mapView:viewForAnnotation:] was called,
    and then if the annotation was scrolled off and then on screen again, we did not add the new view to the container view because it was not happening in the normal addAnnotation cycle. This adds add logic to catch that case and add annotation views created in this way to the view.

Nonte that it is still advisable to use the resuse queue as shown in our annotation view example. Also, once #6055 lands, we will be able to clean this up even more. But, for now, this restores the unoptimized annotation view functionality that I think we were unintentionally not supporting.

cc @incanus @1ec5 @frederoni

This fixes an issue where the map view would drop annotation views
if the developer did not make full use of the reuse queue. The
fixes are:

- Guard against enqueuing a view for reuse if it does not have
a `viewReuseIdentifier`. Previously, if the app developer created a new
annotation view with no reuse id each time
`[MGLMapViewDelegate mapView:viewForAnnotation:]` was called and then
the view was scrolled offscreen, we  attempted to add the view to the
reuse queue (for no good reason) and  did not update the views center
ever again.  This change avoids the reuse queue and just updates the
center always.

- Add any annotation view that should be displayed but is not in the
annotation container view to the annotation container view. Previously,
if the app developer created a new annotation view with a reuse id
each time `[MGLMapViewDelegate mapView:viewForAnnotation:]` was called,
and then if the annotation was scrolled off and then on screen again,
we did not add the new view to the container view because it was
not happening in the normal `addAnnotation` cycle. This adds add
logic to catch that case and add annotation views created in this
way to the view.
@boundsj boundsj added bug iOS Mapbox Maps SDK for iOS annotations Annotations on iOS and macOS or markers on Android labels Sep 27, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Sep 27, 2016
@boundsj boundsj self-assigned this Sep 27, 2016
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

Looks good, but don't forget to mention this fix in the changelog.

@boundsj
Copy link
Contributor Author

boundsj commented Sep 27, 2016

Thanks for the reminder. I updated the changelog in 4e0a026

@boundsj boundsj merged commit 73baa52 into master Sep 27, 2016
@boundsj boundsj deleted the boundsj-annotation-view-edge-cases branch November 23, 2016 19:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants