summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@gmail.com>2019-04-17 15:06:46 -0400
committerGitHub <noreply@github.com>2019-04-17 15:06:46 -0400
commitdfb88e35419cb9a5357263fd78c99d28b5c7102e (patch)
tree5fb951409a936d49b63a3a86a49e4a399663bd45
parent38a4caa3f4ddc5f047288e731273dc6534496495 (diff)
downloadqtlocation-mapboxgl-dfb88e35419cb9a5357263fd78c99d28b5c7102e.tar.gz
[ios] Consider anchored UIView callouts when deciding whether to enable presentsWithTransaction (#14445)
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/src/MGLMapView.mm39
2 files changed, 29 insertions, 11 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index d20967c600..7ecac6a86d 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -8,6 +8,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Fix a bug that wrong position of attribution dialog after rotation. ([#14185](https://github.com/mapbox/mapbox-gl-native/pull/14185))
* Fixed a bug where non-opaque `UIColor` values were ignored when assigned to a style layer color property. ([#14406](https://github.com/mapbox/mapbox-gl-native/pull/14406))
* Speculatively fixed a bug where GL rendering could occur in the background. ([#14439](https://github.com/mapbox/mapbox-gl-native/pull/14439))
+* Fixed a bug with jittery callout views when using sprite-based annotations. ([#14445](https://github.com/mapbox/mapbox-gl-native/pull/14445))
## 4.10.0
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 9a0fcd242a..cadf5be3fd 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -255,7 +255,7 @@ public:
@property (nonatomic) MGLAnnotationContainerView *annotationContainerView;
@property (nonatomic) MGLUserLocation *userLocation;
@property (nonatomic) NSMutableDictionary<NSString *, NSMutableArray<MGLAnnotationView *> *> *annotationViewReuseQueueByIdentifier;
-@property (nonatomic) BOOL enablePresentsWithTransaction;
+@property (nonatomic, readonly) BOOL enablePresentsWithTransaction;
@property (nonatomic) UIImage *lastSnapshotImage;
/// Experimental rendering performance measurement.
@@ -1286,19 +1286,17 @@ public:
[self updateDisplayLinkPreferredFramesPerSecond];
}
-- (void)setEnablePresentsWithTransaction:(BOOL)enablePresentsWithTransaction
+- (void)updatePresentsWithTransaction
{
- if (_enablePresentsWithTransaction == enablePresentsWithTransaction)
- {
- return;
- }
+ BOOL hasEnoughViewAnnotations = (self.annotationContainerView.annotationViews.count > MGLPresentsWithTransactionAnnotationCount);
+ BOOL hasAnAnchoredCallout = [self hasAnAnchoredAnnotationCalloutView];
- _enablePresentsWithTransaction = enablePresentsWithTransaction;
+ _enablePresentsWithTransaction = (hasEnoughViewAnnotations || hasAnAnchoredCallout);
// If the map is visible, change the layer property too
if (self.window) {
CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
- eaglLayer.presentsWithTransaction = enablePresentsWithTransaction;
+ eaglLayer.presentsWithTransaction = _enablePresentsWithTransaction;
}
}
@@ -2349,6 +2347,10 @@ public:
{
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, calloutView);
+
+ [self updatePresentsWithTransaction];
+
+ // TODO: Add sibling disappear method
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
@@ -4339,7 +4341,7 @@ public:
[_glView insertSubview:newAnnotationContainerView atIndex:0];
self.annotationContainerView = newAnnotationContainerView;
- self.enablePresentsWithTransaction = (self.annotationContainerView.annotationViews.count > MGLPresentsWithTransactionAnnotationCount);
+ [self updatePresentsWithTransaction];
}
/// Initialize and return a default annotation image that depicts a round pin
@@ -4513,8 +4515,6 @@ public:
annotationView.annotation = nil;
[annotationView removeFromSuperview];
[self.annotationContainerView.annotationViews removeObject:annotationView];
-
- self.enablePresentsWithTransaction = (self.annotationContainerView.annotationViews.count > MGLPresentsWithTransactionAnnotationCount);
if (annotationTag == _selectedAnnotationTag)
{
@@ -4537,6 +4537,8 @@ public:
self.mbglMap.removeAnnotation(annotationTag);
}
+ [self updatePresentsWithTransaction];
+
[self didChangeValueForKey:@"annotations"];
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
if (_isChangingAnnotationLayers)
@@ -5214,6 +5216,8 @@ public:
{
[self.delegate mapView:self didDeselectAnnotationView:annotationView];
}
+
+ [self updatePresentsWithTransaction];
}
}
@@ -6440,6 +6444,19 @@ public:
}
}
+- (BOOL)hasAnAnchoredAnnotationCalloutView
+{
+ // TODO: Remove duplicate code.
+ UIView <MGLCalloutView> *calloutView = self.calloutViewForSelectedAnnotation;
+ id <MGLAnnotation> annotation = calloutView.representedObject;
+
+ BOOL isAnchoredToAnnotation = (calloutView
+ && annotation
+ && [calloutView respondsToSelector:@selector(isAnchoredToAnnotation)]
+ && calloutView.isAnchoredToAnnotation);
+ return isAnchoredToAnnotation;
+}
+
- (void)updateCalloutView
{
UIView <MGLCalloutView> *calloutView = self.calloutViewForSelectedAnnotation;