tabBarItem's title didn't appear
i am using a tab bar in a view controller and in "viewDidLoad" method i declare it:
normalView =[[NormalViewController alloc] initWithSigne:[[normalAstro objectAtIndex:signIndex]objectForKey :@"name"] andDescription:[[normalAstro objectAtIndex:signIndex]objectForKey :@"description"]] ;
[controllers addObject:normalView];
chineseIndex=[self searchChineseIndex];
chineseView =[[ChineseViewController alloc] initWithSigne:[[chineseAstro objec开发者_StackOverflowtAtIndex:chineseIndex]objectForKey :@"name"] andDescription:[[chineseAstro objectAtIndex:chineseIndex]objectForKey :@"description"]] ;
[controllers addObject:chineseView];
tabBar = [[UITabBarController alloc] init];
tabBar.viewControllers=controllers;
[self.view addSubview:tabBar.view ];
and the viewControllers that are putted in the tabBar i write this to init them:
[self.tabBarItem setTitle:@"signe astral" ] ;
the problem that the title of the tabBarItem didn't appear for me ,so my question where is my mistake in all of this?
Just you have to decalre in,
self.title = @"signe astral";
If you want title and images in your tab bar. So you have to use this code.
UIImage *img = [UIImage imageNamed:@"sss.png"];
self.tabBar = [[[UITabBarItem alloc] initWithTitle:@"signe astral" image:img tag:1] autorelease];
Thanks.
Use
self.title = @"signe astral";
to set the title of the UIViewController, not on self.tabBarItem
.
精彩评论