[ios] Only use non nil presentationLayers to adjust annotation views (#7626)

Views that are added outside of the viewport do not always have an
instantiated presentationLayer. Attempting to use a nil
presentationLayer to move a view offscreen resulted in the view
being pinned to the left side of the view port (at x == 0).
This commit is contained in:
Jesse Bounds
2017-01-08 12:53:23 -08:00
committed by GitHub
parent d3a2ffe747
commit 901c806916

View File

@@ -4797,7 +4797,12 @@ public:
else
{
CGRect adjustedFrame = annotationView.frame;
adjustedFrame.origin.x = CGRectGetWidth(annotationView.layer.presentationLayer.frame) * -2.0;
if (annotationView.layer.presentationLayer) {
adjustedFrame.origin.x = -CGRectGetWidth(annotationView.layer.presentationLayer.frame) * 10.0;
} else {
// views that are added off screen do not have a presentationLayer
adjustedFrame.origin.x = -CGRectGetWidth(adjustedFrame) * 10.0;
}
annotationView.frame = adjustedFrame;
[self enqueueAnnotationViewForAnnotationContext:annotationContext];
}