我AppDelegate.h自定义导航控制器的所有ViewControllers
//
// 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
我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;
}
我也有空的UINavigationController。
我想要实现的东西是定制的导航栏对于使用它 举例而言,所有viewcontrollers:现在我只有两个viewcontrollers,现在我把self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
在viewDidLoad方法中ExamViewController.m和SignsViewController.m 但可能是我我想添加两个或多个标签,并想在一个地方自定义导航栏。 所以问题是:如何自定义导航栏在一个地方看每个viewcontroller相同,而无需在viewDidLoad方法中的每个viewcontroller中定制它?
我有文件夹模板和我AppNavigationController奠定了那里,这个问题如何自定义它的观点。 – nazarov
谢谢,我已经把self.navigationBar.barStyle = UIBarStyleBlackOpaque;在AppNavigationController的viewDidLoad方法中。我试图把self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;之前但没有结果。 – nazarov