diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-09-24 10:58:27 -0400 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2019-10-03 23:11:38 -0400 |
commit | 0c4d49fbb2bb7256876362256f67172457af3288 (patch) | |
tree | f5bbb9640858baa76be6ca80a9e6e5780cd463af | |
parent | 1ae1656239a44b8145187b4c29ef7a61bc774a65 (diff) | |
download | qtlocation-mapboxgl-0c4d49fbb2bb7256876362256f67172457af3288.tar.gz |
[ios] Stop integration tests asserting (when scale bar is hidden). Also reduces the # of calculations (since updateConstraints and layoutSubviews can be called outside of our control).
-rw-r--r-- | platform/ios/src/MGLScaleBar.mm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index 24b0914688..935e2526d4 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -87,6 +87,7 @@ static const MGLRow MGLImperialTable[] ={ @property (nonatomic) MGLScaleBarLabel* prototypeLabel; @property (nonatomic) CGFloat lastLabelWidth; @property (nonatomic, readwrite) CGSize size; +@property (nonatomic) BOOL recalculateSize; @property (nonatomic) BOOL shouldLayoutBars; @end @@ -290,6 +291,8 @@ static const CGFloat MGLScaleBarMinimumBarWidth = 30.0; // Arbitrary _metersPerPoint = metersPerPoint; [self updateVisibility]; + + self.recalculateSize = YES; [self invalidateIntrinsicContentSize]; } @@ -311,6 +314,11 @@ static const CGFloat MGLScaleBarMinimumBarWidth = 30.0; // Arbitrary /// label - (void)updateConstraints { + if (self.isHidden || !self.recalculateSize) { + [super updateConstraints]; + return; + } + // TODO: Improve this (and the side-effects) self.row = [self preferredRow]; @@ -338,7 +346,7 @@ static const CGFloat MGLScaleBarMinimumBarWidth = 30.0; // Arbitrary self.size = CGSizeMake(totalBarWidth + halfLabelWidth, 16); [self setNeedsLayout]; - [super updateConstraints]; + [super updateConstraints]; // This calls intrinsicContentSize } - (void)updateVisibility { @@ -465,6 +473,11 @@ static const CGFloat MGLScaleBarMinimumBarWidth = 30.0; // Arbitrary - (void)layoutSubviews { [super layoutSubviews]; + if (!self.recalculateSize) { + return; + } + + self.recalculateSize = NO; // If size is 0, then we keep the existing layout (which will fade out) if (self.size.width <= 0.0) { |