I am surprised that they did not ask "more" about this :-)
My application is a standard tab bar controller with multiple sections. Each section (tab) contains a navigation controller that controls several view controllers (your basic view type is tableview + detailview). Now that I have added the 6th tab, iOS creates the Advanced tab, which manages the last two tabs. I need to remove the text “More” in the middle of the navigation bar (Note: not the button text, nor the title of the tab itself), and also apply a custom background image to the navigation bar.
Note. This question is about setting up the More navigation bar. I successfully changed the background image and the title text on all the navigation bars created outside of iOS.
In my application application, the application develops as follows:
Create view controllers:
ViewController1 *vc1 = [ViewController1 alloc] initWithNibName@ "View1" bundle:nil]; vc1.title = @"VC1"; vc1.tabBarImage.image = [UIImage imageNamed:@"image1.png"];
Repeat the above procedure 5 more times for controllers of the form vc2-vc6.
Create separate navigation controllers:
UINavigationController *nc1 = [UINavigationController alloc] initWithRootViewController:vc1];
Repeat 5 more times for nc2 - nc6 navigation controllers.
Add Nav controllers to tab bar controller
self.tabBarController.viewControllers = [NSArray arrayWithObjects: vc1, vc2, vc3, vc4, vc5, vc6, nil];
All code above works fine. No problems.
Then I add a custom background image to the navigation controller More:
if (self.tabBarController.moreNavigationController){ if ([self.tabBarController.moreNavigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) { UIImage *image = [UIImage imageNamed:@"navlogo.png"]; [self.tabBarController.moreNavigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; } else { UINavigationBar *navbar = self.tabBarController.moreNavigationController.navigationBar; UIImage *headerImg = [UIImage imageNamed:@"navlogo.png"]; [navbar setBackgroundImage:headerImg forBarMetrics:UIBarMetricsDefault]; } }
This also works great. No problems
Since my custom background contains the dead center of the customer’s logo, I need to remove the titleView text, which reads “More” by default. Notice I'm not talking about the text DIRECTION BUTTONS, but the label in the middle of the navigation bar.
Logically, one could assume that this would work:
UILabel *label = [[UILabel alloc] init]; label.text = @""; self.tabBarController.moreNavigationController.navigationItem.titleView = label;
... because I do this in all individual view controllers, replacing self.navigationItem.titleView with self.tabBarController.moreNavigationController, etc.
But that will not work! I can successfully change both the background image and the titleView text on all of my navigation controllers using this same code (again, replacing self.navigationController.navigationItem with moreNavController material ...). However, in the application delegate, I can only set the background image, but not the titleView of the More navigation controller More.
Any solutions would be very helpful.
B. B.