Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Issues With Customizing Color Of NavigationController

Hi there!

I´m working on a project using Tab Bars and Storyboards.

In my tab bar application i have been trying to program different things, everything from making the tab bars save when application terminates, creating actionsheet popup when one of the tabs are pressed, but everything ends with nothing happening… Even when i try to change the color of the navigation bar in the "more" tab in the tab bar controller, it don´t work...



I guess there must be something that i am doing wrong, something that is not implemented the right way or something… But i know one thing, that i really need some help.



I will take an example when it comes to changing the color of the navigation bar in the "more" tab in the tab bar controller.



I have first in the AppDelegate.h done this.



@interface AppDelegate : UIResponder <UIApplicationDelegate, UINavigationControllerDelegate, UITabBarControllerDelegate>

{

UIWindow *window;

}



@property (nonatomic, retain) UIWindow *window;

@property (nonatomic, retain) UITabBarController *mytab;



@end



Then in the implementation file AppDelegate.m i have done the following





#import "AppDelegate.h"



@implementation AppDelegate



@synthesize window = _window;

@synthesize mytab;



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

mytab.moreNavigationController.navigationBar.tintColor = [UIColor orangeColor];

// Override point for customization after application launch.

return YES;

}






When I do this i get no error messages, no issues, nothing that indicates that something is wrong. The application is running just as it should, except that the "more" navigation bar color is not changed…





Please help me with this, Im basically stuck with everything right now due to these problems. Keep in mind that i´m using Storyboards with the Tab Bar starting template.



Cheers

iPhone 4S, iOS 5.1

Posted on May 11, 2012 1:30 PM

Reply
Question marked as Best reply

Posted on May 12, 2012 9:59 AM

> when i try to change the color of the navigation bar in the "more" tab in the tab bar controller, it don´t work...


If the code you provided is complete, you have declared a property mytab but are never setting that property to anything.


If you create a new project from the Tabbed Application template and add enough view controllers to the storyboard to show the More tab, you only need these two lines of code.


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

// assumes root view contoller in storyboard is a tab bar controller

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

tabBarController.moreNavigationController.navigationBar.tintColor = UIColor.orangeColor;

returnYES;

}


Declaring properties, marking the AppDelegate with additional protocols, etc. is not necessary just for this.


You also have something strange with the window property. It looks like you added instance variable UIWindow *window to the AppDelegate interface, but left the default @synthesize window = _window in the implementation. So the property window uses _window, not the window you declared. That extra window instance variable could lead to an error. The @synthesize directive also synthesizes an appropriate instance variable, so unless you have a very good reason don't create your own.

1 reply
Question marked as Best reply

May 12, 2012 9:59 AM in response to Klafstad

> when i try to change the color of the navigation bar in the "more" tab in the tab bar controller, it don´t work...


If the code you provided is complete, you have declared a property mytab but are never setting that property to anything.


If you create a new project from the Tabbed Application template and add enough view controllers to the storyboard to show the More tab, you only need these two lines of code.


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

// assumes root view contoller in storyboard is a tab bar controller

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

tabBarController.moreNavigationController.navigationBar.tintColor = UIColor.orangeColor;

returnYES;

}


Declaring properties, marking the AppDelegate with additional protocols, etc. is not necessary just for this.


You also have something strange with the window property. It looks like you added instance variable UIWindow *window to the AppDelegate interface, but left the default @synthesize window = _window in the implementation. So the property window uses _window, not the window you declared. That extra window instance variable could lead to an error. The @synthesize directive also synthesizes an appropriate instance variable, so unless you have a very good reason don't create your own.

Issues With Customizing Color Of NavigationController

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.