Reputation: 167
My AppDelegate.h
//
// AppDelegate.h
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UIWindow *window;
UITabBarController *tabBarController;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@end
My AppDelegate.m
//
// AppDelegate.m
//
#import "AppDelegate.h"
#import "AppNavigationController.h"
#import "ExamViewController.h"
#import "SignsViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
- (void)dealloc
{
[_tabBarController release];
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
// Initializating our Tab Bar Controller
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
// Exam Controller Setup
ExamViewController *examViewController = [[ExamViewController alloc] initWithStyle:UITableViewStylePlain];
AppNavigationController *examNavigationController = [[AppNavigationController alloc] initWithRootViewController:examViewController];
examViewController.title = @"Экзамен";
examViewController.tabBarItem.image = [UIImage imageNamed:@"icon_exam.png"];
// -------------------------------------
// Signs Controller Setup
SignsViewController *signsViewController = [[SignsViewController alloc] initWithStyle:UITableViewStylePlain];
AppNavigationController *signsNavigationController = [[AppNavigationController alloc] initWithRootViewController:signsViewController];
signsViewController.title = @"Знаки";
signsViewController.tabBarItem.image = [UIImage imageNamed:@"icon_signs.png"];
// -------------------------------------
[tabBarController setViewControllers:[NSArray arrayWithObjects:examNavigationController, signsNavigationController, nil]];
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
[examNavigationController release];
[examViewController release];
[signsNavigationController release];
[signsViewController release];
return YES;
}
Also I have empty UINavigationController.
The thing I want to implement is customized navigation bar for all viewcontrollers which use it
For example: Now I have only two viewcontrollers and now I put self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
in viewDidLoad method in ExamViewController.m and SignsViewController.m
But probably I'd like to add two or more tabs and want to customize navigation bar in one place.
So the question is: How to customize navigation bar in one place to look the same in every viewcontroller without customizing it in each viewcontroller in viewDidLoad method?
Upvotes: 3
Views: 1143
Reputation: 7344
If you are using iOS 5 only a new way would be UIAppearence
. See here: Custom Appearance for UIKit Controls
And here is another great Tutorial how to customize UI in iOS 5 by Steve Baranski: User Interface Customization in iOS 5
Upvotes: 1
Reputation: 19869
Try this:.
Then each time you want to crate a view controller just set the ViewControllerTemplate.h as its super class, and it will inherit the design.
ViewControllerTemplate *newController = [[ViewControllerTemplate alloc]init];
Upvotes: 3