From 15448a623e57061ff11a0c7cf6316ecb6a718c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 30 Oct 2015 16:05:34 -0700 Subject: Create UIActionSheet on demand Fixes #2475. --- platform/ios/MGLMapView.mm | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'platform') 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]; } -- cgit v1.2.1