From 897cbd91c61685ee10367d128961eedddfe69f57 Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Mon, 25 Mar 2024 14:33:46 +0400 Subject: [PATCH] [ios] fix: add titles for the back button for ios>14.0 Signed-off-by: Kiryl Kaveryn --- .../Components/MWMNavigationController.m | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/iphone/Maps/Classes/Components/MWMNavigationController.m b/iphone/Maps/Classes/Components/MWMNavigationController.m index 446d61c511..7e67c46c4a 100644 --- a/iphone/Maps/Classes/Components/MWMNavigationController.m +++ b/iphone/Maps/Classes/Components/MWMNavigationController.m @@ -43,10 +43,7 @@ - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { UIViewController * topVC = self.viewControllers.lastObject; - topVC.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" - style:UIBarButtonItemStylePlain - target:nil - action:nil]; + [self setupNavigationBackButtonItemFor:topVC]; [super pushViewController:viewController animated:animated]; } @@ -54,11 +51,7 @@ [viewControllers enumerateObjectsUsingBlock:^(UIViewController * vc, NSUInteger idx, BOOL * stop) { if (idx == viewControllers.count - 1) return; - - vc.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" - style:UIBarButtonItemStylePlain - target:nil - action:nil]; + [self setupNavigationBackButtonItemFor:vc]; }]; [super setViewControllers:viewControllers animated:animated]; } @@ -75,4 +68,15 @@ return YES; } +- (void)setupNavigationBackButtonItemFor:(UIViewController *)viewController { + if (@available(iOS 14.0, *)) { + viewController.navigationItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal; + } else { + viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" + style:UIBarButtonItemStylePlain + target:nil + action:nil]; + } +} + @end