1

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 objectAtIndex: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?

Mejdi Lassidi
  • 999
  • 10
  • 22

2 Answers2

0

Use

self.title = @"signe astral";

to set the title of the UIViewController, not on self.tabBarItem.

Eiko
  • 25,601
  • 15
  • 56
  • 71
  • I found the opposite - when I tried setting the controller title, it would just end up blank, but when I set the `tabBarItem` title, then it'd work – Casebash Mar 29 '11 at 02:14
  • Okay, so I did some more investigation. When both self.title and self.tabBarItem.title are set then no title displays. Both of these properties can be set via interface builder, which makes things more confusing – Casebash Mar 29 '11 at 04:56
  • Thanks for the downvote. It was an answer to Dingua a year ago. If you need help you should post your code and not downvote a working solution. – Eiko Mar 29 '11 at 07:58
0

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.

Pugalmuni
  • 9,350
  • 8
  • 56
  • 97