我在其中一个选项卡的UIViewController中执行此操作:
self.title = @"Welcome";
但是,它会覆盖我在tabBarItem上拥有的所有内容。我试过了:
self.tabBarItem.title = @"Home";
和
[self.tabBarItem initWithTitle:@"Home" image:[UIImage imageNamed:@"iconHome.png"] tag:0];
但是,无论我是否在设置标题之后尝试后两段代码,self.title都会覆盖tabBarItem。代码甚至可以无错误地运行,但是self.tabBarItem.title
或initWithTitle
什么也不做?
发布于 2009-10-21 01:54:44
好了,我想通了!下面是我正在做的事情:
self.title = @"Title for TabBarItem"; // TabBarItem.title inherits the viewController's self.title
self.navigationItem.title = @"Title for NavigationBar";
除非使用self.navigationItem.title
另行设置,否则navigationBar
将继承self.title
发布于 2009-10-08 22:17:57
尝试:
[self setTitle:@"Welcome"];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"Home" image:[UIImage imageNamed: image] tag:0];
[self setTabBarItem:item];
[item release];
发布于 2010-08-31 01:41:58
我也面临着同样的问题,但我这样解决了这个问题。在appDelegate中创建tabBarItem之后,我设置了它们的标题和图像。
这就是我所做的:
[viewController setTitle:@"controllerTitle"];
[[viewController tabBarItem] setTitle:@"Custome Title for tab"];
[[viewController tabBarItem] setImage:[UIImage imageNamed:@"tab.png"]];
https://stackoverflow.com/questions/1540718
复制相似问题