[ios] properly show attribution in modal hierarchies (#8837)
fixes #8782
This commit is contained in:
committed by
Jordan Kiley
parent
5c52401d55
commit
e5ae80ca96
@@ -42,12 +42,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"
|
||||
@@ -1946,10 +1947,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];
|
||||
|
||||
11
platform/ios/src/UIViewController+MGLAdditions.h
Normal file
11
platform/ios/src/UIViewController+MGLAdditions.h
Normal file
@@ -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
|
||||
22
platform/ios/src/UIViewController+MGLAdditions.m
Normal file
22
platform/ios/src/UIViewController+MGLAdditions.m
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user