mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 13:16:58 +02:00
Use protocol to get title from child VCs.
This commit is contained in:
@@ -316,7 +316,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
titleView.titleLabel.text = self.selectedViewController.accessibilityLabel;
|
||||
titleView.titleLabel.text = [self getTitleForItemViewController:self.selectedViewController];
|
||||
|
||||
// Need to be called in case of the controllers have been replaced
|
||||
[self.selectedViewController viewDidAppear:NO];
|
||||
@@ -336,6 +336,8 @@
|
||||
{
|
||||
NSInteger index = [self indexOfTabItemWithTag:tabBarIndex];
|
||||
self.selectedIndex = index;
|
||||
|
||||
titleView.titleLabel.text = [self getTitleForItemViewController:self.selectedViewController];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@@ -825,6 +827,17 @@
|
||||
self.navigationController.navigationBar.hidden = hidden;
|
||||
}
|
||||
|
||||
- (NSString*)getTitleForItemViewController:(UIViewController*)itemViewController
|
||||
{
|
||||
if ([itemViewController conformsToProtocol:@protocol(MasterTabBarItemDisplayProtocol)])
|
||||
{
|
||||
UIViewController<MasterTabBarItemDisplayProtocol> *masterTabBarItem = (UIViewController<MasterTabBarItemDisplayProtocol>*)itemViewController;
|
||||
return masterTabBarItem.masterTabBarItemTitle;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)refreshTabBarBadges
|
||||
@@ -1115,7 +1128,7 @@
|
||||
|
||||
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
|
||||
{
|
||||
titleView.titleLabel.text = viewController.accessibilityLabel;
|
||||
titleView.titleLabel.text = [self getTitleForItemViewController:viewController];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc protocol MasterTabBarItemDisplayProtocol {
|
||||
var masterTabBarItemTitle: String { get }
|
||||
}
|
||||
Reference in New Issue
Block a user