diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2015-03-03 11:46:20 -0800 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-03-03 11:46:20 -0800 |
commit | 28228bfae0020f9d379dbcbb1834e5d898956750 (patch) | |
tree | 5d219f8df2c700d588cbc68434a8f6e6fb88d231 /ios | |
parent | 6171cbb748facf9a783661316fc045d70ff9e7dc (diff) | |
download | qtlocation-mapboxgl-28228bfae0020f9d379dbcbb1834e5d898956750.tar.gz |
ensure correct ordering for bundled styles
Diffstat (limited to 'ios')
-rw-r--r-- | ios/app/MBXViewController.mm | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index 569eaec6c8..0e0e73c4db 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -8,12 +8,14 @@ static UIColor *const kTintColor = [UIColor colorWithRed:0.120 green:0.550 blue:0.670 alpha:1.000]; -static NSDictionary *const kStyles = @{ - @"bright-v7": @"Bright", - @"basic-v7": @"Basic", - @"outdoors-v7": @"Outdoors", - @"satellite-v7": @"Satellite" -}; +static NSArray *const kStyleNames = @[ + @"Bright", + @"Basic", + @"Outdoors", + @"Satellite" +]; + +static NSString *const kStyleVersion = @"v7"; @interface MBXViewController () <UIActionSheetDelegate, CLLocationManagerDelegate> @@ -75,7 +77,7 @@ mbgl::Settings_NSUserDefaults *settings = nullptr; UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeCustom]; [titleButton setFrame:CGRectMake(0, 0, 120, 40)]; - [titleButton setTitle:[[kStyles allValues] firstObject] forState:UIControlStateNormal]; + [titleButton setTitle:[kStyleNames firstObject] forState:UIControlStateNormal]; [titleButton setTitleColor:kTintColor forState:UIControlStateNormal]; [titleButton addTarget:self action:@selector(cycleStyles) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.titleView = titleButton; @@ -159,18 +161,21 @@ mbgl::Settings_NSUserDefaults *settings = nullptr; if ( ! styleName) { - styleName = [[kStyles allKeys] firstObject]; + styleName = [kStyleNames firstObject]; } else { - NSUInteger index = [[kStyles allValues] indexOfObject:styleName] + 1; - if (index == [[kStyles allKeys] count]) index = 0; - styleName = [[kStyles allKeys] objectAtIndex:index]; + NSUInteger index = [kStyleNames indexOfObject:styleName] + 1; + if (index == [kStyleNames count]) index = 0; + styleName = [kStyleNames objectAtIndex:index]; } - [self.mapView useBundledStyleNamed:styleName]; + [self.mapView useBundledStyleNamed: + [[[styleName lowercaseString] + stringByAppendingString:@"-"] + stringByAppendingString:kStyleVersion]]; - [titleButton setTitle:kStyles[styleName] forState:UIControlStateNormal]; + [titleButton setTitle:styleName forState:UIControlStateNormal]; } - (void)locateUser |