使用以下代碼創建了uitabbarview controller
在uitabbarview controller中我想為每一個視圖顯示標題
怎麼樣為每個視圖添加標題呢(標題欄項目)?
myTabBarController = [[UITabBarController alloc] init];
MyDialerViewController *aDialerViewController = [[MyDialerViewController alloc]init];
MyCallLogViewController *aCallLogViewController = [[MyCallLogViewController alloc] init];
TemplateViewController *aTemplateViewController = [[TemplateViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:aDialerViewController, aCallLogViewController, aTemplateViewController, nil];
myTabBarController.viewControllers = controllers;
myTabBarController.delegate = self;
myTabBarController.selectedIndex = 0;
[controllers release];
[aDialerViewController release];
[aCallLogViewController release];
[aTemplateViewController release];
[self.window addSubview:myTabBarController.view];
[self.window makeKeyAndVisible];
在appDelegate裡面直接設置navcontroller的標題。同時也在viewcontroller裡面的viewDidLoad 中設置。
aDialerViewController.title = NSLocalizedString(@"Dialer Title", @"Dialer Title");
aCallLogViewController.title = @"Title";
aTemplateViewController.title = @"Title";