diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-10-30 16:05:34 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-10-30 16:05:34 -0700 |
commit | 15448a623e57061ff11a0c7cf6316ecb6a718c52 (patch) | |
tree | 8f66772c4bff82dc9d0234f94d0fb5661969ba78 | |
parent | 009930ab8edbc5bf06a1da296ea5e6e09ad697db (diff) | |
download | qtlocation-mapboxgl-15448a623e57061ff11a0c7cf6316ecb6a718c52.tar.gz |
Create UIActionSheet on demand
Fixes #2475.
-rw-r--r-- | platform/ios/MGLMapView.mm | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index cf054f8722..078841bbb0 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -276,22 +276,6 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) [self addSubview:_attributionButton]; _attributionButtonConstraints = [NSMutableArray array]; - _attributionSheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox iOS SDK" - delegate:self - cancelButtonTitle:@"Cancel" - destructiveButtonTitle:nil - otherButtonTitles: - @"© Mapbox", - @"© OpenStreetMap", - @"Improve This Map", - nil]; - - // iOS 8+: add action that opens app's Settings.app panel, if applicable - if (&UIApplicationOpenSettingsURLString != NULL && ! [MGLAccountManager mapboxMetricsEnabledSettingShownInApp]) - { - [_attributionSheet addButtonWithTitle:@"Adjust Privacy Settings"]; - } - // setup compass // _compassView = [[UIImageView alloc] initWithImage:[MGLMapView resourceImageNamed:@"Compass.png"]]; @@ -1473,6 +1457,25 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) - (void)showAttribution { + if ( ! self.attributionSheet) + { + self.attributionSheet = [[UIActionSheet alloc] initWithTitle:@"Mapbox iOS SDK" + delegate:self + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:nil + otherButtonTitles: + @"© Mapbox", + @"© OpenStreetMap", + @"Improve This Map", + nil]; + + // iOS 8+: add action that opens app's Settings.app panel, if applicable + if (&UIApplicationOpenSettingsURLString != NULL && ! [MGLAccountManager mapboxMetricsEnabledSettingShownInApp]) + { + [self.attributionSheet addButtonWithTitle:@"Adjust Privacy Settings"]; + } + } + [self.attributionSheet showFromRect:self.attributionButton.frame inView:self animated:YES]; } |