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

Commit

Permalink
[ios] Fix bug where scale bar shows 0 mm instead of 0 (#15381)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkiley authored Aug 20, 2019
1 parent dcf77fb commit 5d1ed5d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions platform/ios/src/MGLScaleBar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ @interface MGLScaleBar()
@property (nonatomic) UIColor *secondaryColor;
@property (nonatomic) CALayer *borderLayer;
@property (nonatomic, assign) CGFloat borderWidth;
@property (nonatomic) NSCache* labelImageCache;
@property (nonatomic) NSMutableDictionary* labelImageCache;
@property (nonatomic) MGLScaleBarLabel* prototypeLabel;
@property (nonatomic) CGFloat lastLabelWidth;

Expand Down Expand Up @@ -159,7 +159,7 @@ - (void)commonInit {
_formatter = [[MGLDistanceFormatter alloc] init];

// Image labels are now images
_labelImageCache = [[NSCache alloc] init];
_labelImageCache = [[NSMutableDictionary alloc] init];
_prototypeLabel = [[MGLScaleBarLabel alloc] init];
_prototypeLabel.font = [UIFont systemFontOfSize:8 weight:UIFontWeightMedium];
_prototypeLabel.clipsToBounds = NO;
Expand All @@ -180,6 +180,17 @@ - (void)commonInit {

// Zero is a special case (no formatting)
[self addZeroLabel];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resetLabelImageCache) name:NSCurrentLocaleDidChangeNotification object:nil];
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)resetLabelImageCache {
self.labelImageCache = [[NSMutableDictionary alloc] init];
[self addZeroLabel];
}

#pragma mark - Dimensions
Expand Down

0 comments on commit 5d1ed5d

Please sign in to comment.