开发者

tabBarItem's title didn't appear

开发者 https://www.devze.com 2023-01-02 19:54 出处:网络
i am using a tab bar in a view controllerand in \"viewDidLoad\" method i declare it: normalView =[[NormalViewController alloc] initWithSigne:[[normalAstro objectAtIndex:signIndex]objectForKey :@\"nam

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消