summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJordan Kiley <jmkiley@users.noreply.github.com>2017-05-02 16:20:34 -0700
committerGitHub <noreply@github.com>2017-05-02 16:20:34 -0700
commita70f8911c611553ba3b40ec463075ee09c8ece75 (patch)
tree6d3e276bc8c28cf6f5cff00ac2eac7794921ee6e /platform
parenta3e4e67ea68c455178d5c5ef3d864972fcf41147 (diff)
downloadqtlocation-mapboxgl-a70f8911c611553ba3b40ec463075ee09c8ece75.tar.gz
[ios] cherry-picked 8837 (#8869)
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj16
-rw-r--r--platform/ios/src/MGLMapView.mm12
-rw-r--r--platform/ios/src/UIViewController+MGLAdditions.h11
-rw-r--r--platform/ios/src/UIViewController+MGLAdditions.m22
4 files changed, 52 insertions, 9 deletions
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 9a87f2c631..d856424be2 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -450,6 +450,10 @@
DD4823761D94AE6C00EB71B7 /* line_filter_style.json in Resources */ = {isa = PBXBuildFile; fileRef = DD4823731D94AE6C00EB71B7 /* line_filter_style.json */; };
DD4823771D94AE6C00EB71B7 /* numeric_filter_style.json in Resources */ = {isa = PBXBuildFile; fileRef = DD4823741D94AE6C00EB71B7 /* numeric_filter_style.json */; };
DD58A4C61D822BD000E1F038 /* MGLExpressionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD58A4C51D822BD000E1F038 /* MGLExpressionTests.mm */; };
+ DD9BE4F71EB263C50079A3AF /* UIViewController+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DD9BE4F51EB263C50079A3AF /* UIViewController+MGLAdditions.h */; };
+ DD9BE4F81EB263C50079A3AF /* UIViewController+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DD9BE4F61EB263C50079A3AF /* UIViewController+MGLAdditions.m */; };
+ DD9BE4F91EB263D20079A3AF /* UIViewController+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DD9BE4F51EB263C50079A3AF /* UIViewController+MGLAdditions.h */; };
+ DD9BE4FA1EB263F40079A3AF /* UIViewController+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DD9BE4F61EB263C50079A3AF /* UIViewController+MGLAdditions.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -905,6 +909,8 @@
DD4823731D94AE6C00EB71B7 /* line_filter_style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = line_filter_style.json; sourceTree = "<group>"; };
DD4823741D94AE6C00EB71B7 /* numeric_filter_style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = numeric_filter_style.json; sourceTree = "<group>"; };
DD58A4C51D822BD000E1F038 /* MGLExpressionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLExpressionTests.mm; path = ../../darwin/test/MGLExpressionTests.mm; sourceTree = "<group>"; };
+ DD9BE4F51EB263C50079A3AF /* UIViewController+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MGLAdditions.h"; sourceTree = "<group>"; };
+ DD9BE4F61EB263C50079A3AF /* UIViewController+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MGLAdditions.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -1060,12 +1066,14 @@
35CE617F1D4165C2004F2359 /* Categories */ = {
isa = PBXGroup;
children = (
+ 357FE2DB1E02D2B20068B753 /* NSCoder+MGLAdditions.h */,
+ 357FE2DC1E02D2B20068B753 /* NSCoder+MGLAdditions.mm */,
35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.h */,
35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */,
30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */,
30E578121DAA7D690050F07E /* UIImage+MGLAdditions.mm */,
- 357FE2DB1E02D2B20068B753 /* NSCoder+MGLAdditions.h */,
- 357FE2DC1E02D2B20068B753 /* NSCoder+MGLAdditions.mm */,
+ DD9BE4F51EB263C50079A3AF /* UIViewController+MGLAdditions.h */,
+ DD9BE4F61EB263C50079A3AF /* UIViewController+MGLAdditions.m */,
);
name = Categories;
sourceTree = "<group>";
@@ -1592,6 +1600,7 @@
DA88485A1CBAFB9800AB86E3 /* MGLUserLocation_Private.h in Headers */,
DA27C24F1CBB4C11000B0ECD /* MGLAccountManager_Private.h in Headers */,
DA8847FC1CBAFA5100AB86E3 /* MGLStyle.h in Headers */,
+ DD9BE4F71EB263C50079A3AF /* UIViewController+MGLAdditions.h in Headers */,
DAF0D8131DFE0EC500B28378 /* MGLVectorSource_Private.h in Headers */,
354B83961D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */,
DA8847F01CBAFA5100AB86E3 /* MGLAnnotation.h in Headers */,
@@ -1702,6 +1711,7 @@
353933FF1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */,
DAAF722E1DA903C700312FA4 /* MGLStyleValue_Private.h in Headers */,
DABFB8661CBE99E500D62B32 /* MGLPointAnnotation.h in Headers */,
+ DD9BE4F91EB263D20079A3AF /* UIViewController+MGLAdditions.h in Headers */,
DABFB8621CBE99E500D62B32 /* MGLOfflinePack.h in Headers */,
DAD1656D1CF41981001FF4B9 /* MGLFeature.h in Headers */,
DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.h in Headers */,
@@ -2138,6 +2148,7 @@
DA8848541CBAFB9800AB86E3 /* MGLCompactCalloutView.m in Sources */,
DA8848251CBAFA6200AB86E3 /* MGLPointAnnotation.mm in Sources */,
35136D3C1D42272500C20EFD /* MGLCircleStyleLayer.mm in Sources */,
+ DD9BE4F81EB263C50079A3AF /* UIViewController+MGLAdditions.m in Sources */,
350098DE1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.mm in Sources */,
DA6408DD1DA4E7D300908C90 /* MGLVectorStyleLayer.m in Sources */,
3566C7681D4A77BA008152BC /* MGLShapeSource.mm in Sources */,
@@ -2216,6 +2227,7 @@
DAA4E4291CBB730400178DFB /* NSBundle+MGLAdditions.m in Sources */,
DAA4E42E1CBB730400178DFB /* MGLAPIClient.m in Sources */,
35136D3D1D42272500C20EFD /* MGLCircleStyleLayer.mm in Sources */,
+ DD9BE4FA1EB263F40079A3AF /* UIViewController+MGLAdditions.m in Sources */,
350098DF1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.mm in Sources */,
DA6408DE1DA4E7D300908C90 /* MGLVectorStyleLayer.m in Sources */,
3566C7691D4A77BA008152BC /* MGLShapeSource.mm in Sources */,
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 540f6de861..4b5ca8679a 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -40,12 +40,13 @@
#import "NSBundle+MGLAdditions.h"
#import "NSDate+MGLAdditions.h"
-#import "NSString+MGLAdditions.h"
-#import "NSProcessInfo+MGLAdditions.h"
#import "NSException+MGLAdditions.h"
+#import "NSPredicate+MGLAdditions.h"
+#import "NSProcessInfo+MGLAdditions.h"
+#import "NSString+MGLAdditions.h"
#import "NSURL+MGLAdditions.h"
#import "UIImage+MGLAdditions.h"
-#import "NSPredicate+MGLAdditions.h"
+#import "UIViewController+MGLAdditions.h"
#import "MGLFaux3DUserLocationAnnotationView.h"
#import "MGLUserLocationAnnotationView.h"
@@ -1917,10 +1918,7 @@ public:
attributionController.popoverPresentationController.sourceView = self;
attributionController.popoverPresentationController.sourceRect = self.attributionButton.frame;
- UIViewController *viewController = self.window.rootViewController;
- if ([viewController isKindOfClass:[UINavigationController class]]) {
- viewController = [(UINavigationController *)viewController viewControllers].firstObject;
- }
+ UIViewController *viewController = [self.window.rootViewController mgl_topMostViewController];
[viewController presentViewController:attributionController
animated:YES
completion:NULL];
diff --git a/platform/ios/src/UIViewController+MGLAdditions.h b/platform/ios/src/UIViewController+MGLAdditions.h
new file mode 100644
index 0000000000..b60375a6f6
--- /dev/null
+++ b/platform/ios/src/UIViewController+MGLAdditions.h
@@ -0,0 +1,11 @@
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface UIViewController (MGLAdditions)
+
+@property (readonly) UIViewController *mgl_topMostViewController;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/ios/src/UIViewController+MGLAdditions.m b/platform/ios/src/UIViewController+MGLAdditions.m
new file mode 100644
index 0000000000..746fdd8db8
--- /dev/null
+++ b/platform/ios/src/UIViewController+MGLAdditions.m
@@ -0,0 +1,22 @@
+#import "UIViewController+MGLAdditions.h"
+
+@implementation UIViewController (MGLAdditions)
+
+- (UIViewController *)mgl_topMostViewController
+{
+ if ([self isKindOfClass:[UINavigationController class]])
+ {
+ return [[(UINavigationController *)self visibleViewController] mgl_topMostViewController];
+ }
+ else if ([self isKindOfClass:[UITabBarController class]])
+ {
+ return [[(UITabBarController *)self selectedViewController] mgl_topMostViewController];
+ }
+ else if (self.presentedViewController)
+ {
+ return [self.presentedViewController mgl_topMostViewController];
+ }
+ return self;
+}
+
+@end