This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
[ios] Removing an annotation does not remove it from mapView.annotationContainerView.annotationViews #8754
Labels
Milestone
Platform: iOS
Mapbox SDK version: master@8eb23cbac8a6c5821dc5935e27689700216c3f1a
Steps to trigger behavior
Expected behavior
mapView.annotationContainerView.annotationViews will contain 0 items
Actual behavior
mapView.annotationContainerView.annotationViews still contains 1 item.
Why this is a problem
Im using a subclass of MGLAnnotationView, that sets
self.annotation = nil
in it'sremoveFromSuperviewMethod
, the annotation property is nullable, so this seems like a legitimate thing to do, and i need to do it to make sure my annotation gets dealloced when it is removed from the map.If the map is later tapped in the same spot where the annotation was,
- (nullable id <MGLAnnotation>)annotationForGestureRecognizer:(UITapGestureRecognizer*)singleTap persistingResults:(BOOL)persist
finds the annotationView, and raises an exception because it's annotation is nil. And since the method call that raised the exception was triggered by a UIGestureRecognizer, there is no way to catch it.Test case
I have tested this by adding the following to MBXViewController.m
and
The text was updated successfully, but these errors were encountered: