2010-06-17 69 views

回答

12

嘿你要设置的标签栏按钮或与该选项卡关联的视图控制器的标题?

如果你正在寻找的第一件事再去做这样的:

UITabBarItem *tabItem = [[[tabBarController tabBar] items] objectAtIndex:yourIndex]; 
[tabItem setTitle:@"theTitle"]; 

否则mihirpmehta是正确的。

希望这会有所帮助。

+1

我试图设置标签栏按钮的标题。 我刚刚做的笏只是提供 self.title = @“Title”; at viewdidload .. 和标签栏以及viewcontroller的标题已被设置为“标题”。 是否正确? – iscavengers 2010-06-17 11:37:59

+0

@ shishir.bobby不能说是否合适 – 2010-06-17 11:41:45

+0

不需要在两个地方设置标题......任何一个都足够了...... – 2010-06-18 06:15:24

0

可以初始化并使用以下功能使用UITabBarItem对象:

- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag; // selected image autogenerated 
- (id)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag 

然后你就可以调用这个方法您的TabBar对象:

- (void)setItems:(NSArray *)items animated:(BOOL)animated; 

其中物品ID的阵列,其你已经添加了所有的tabBarItem对象。如果需要使用,还有一个UITabBarItem的badgeValue属性。

+0

感谢的人, 我只需要programmatially提供的名字,其余的将是相同的... 任何其他方式提供手动标题??? – iscavengers 2010-06-17 10:30:08

5

OR

[(UIViewController *)[tabBarController.viewControllers objectAtIndex:1] setTitle:@"Title1"]; 
+0

这是正确的答案...不投票它只是因为你不明白它,或它不符合你的意见。 – 2010-06-18 06:12:15

0

如果您UIViewController被包裹在一个UINavigationController,请执行下列操作:

self.navigationController?.tabBarItem.title = "Awesome Title" 
相关问题