以下のコードを使用してください...
ここではUINavigationController
、すべてのタブに追加し、タブと以下のようなタイトルも割り当てますUINavigationBar
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
UIViewController *viewController1, *viewController2, *viewController3, *viewController4, *viewController5;
UINavigationController *navviewController1 , *navviewController2, *navviewController3, *navviewController4, *navviewController5;
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[[YourViewController1 alloc] initWithNibName:@"YourViewController1" bundle:nil] autorelease];
navviewController1=[[UINavigationController alloc]initWithRootViewController:viewController1];
navviewController1.title = @"Home";
// navviewController1.navigationBarHidden=YES;
viewController2 = [[[YourViewController2 alloc] initWithNibName:@"YourViewController2" bundle:nil] autorelease];
navviewController2=[[UINavigationController alloc]initWithRootViewController:viewController2];
// navviewController2.navigationBarHidden=YES;
navviewController2.title = @"HowItsWork";
viewController3 = [[[YourViewController3 alloc] initWithNibName:@"YourViewController3" bundle:nil] autorelease];
navviewController3=[[UINavigationController alloc]initWithRootViewController:viewController3];
// navviewController3.navigationBarHidden=YES;
navviewController3.title = @"Join Us";
viewController4 = [[[YourViewController4 alloc] initWithNibName:@"YourViewController4" bundle:nil] autorelease];
navviewController4=[[UINavigationController alloc]initWithRootViewController:viewController4];
// navviewController4.navigationBarHidden=YES;
navviewController4.title = @"Become";
viewController5 = [[[YourViewController5 alloc] initWithNibName:@"YourViewController5" bundle:nil] autorelease];
navviewController5=[[UINavigationController alloc]initWithRootViewController:viewController5];
// navviewController4.navigationBarHidden=YES;
navviewController5.title = @"Contact Us";
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navviewController1, navviewController2,navviewController3,navviewController4,navviewController5, nil];
self.window.rootViewController = self.tabBarController;
}
[self.window makeKeyAndVisible];
}
2) または
また、次のように特定のクラスにタイトルを簡単に割り当てることができます...
-(void)viewWillAppear:(BOOL)animated{
self.title = @"yourTitle";
}
これがお役に立てば幸いです...