UITabBarItem 标题未显示
我有一个 UITabBarController,其中第一个 UITabBarItem 标题未显示。我在 Interface Builder 中设置了它,并尝试以编程方式设置它,但标题区域保持空白。
[[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"Test1"];
[[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"Test2"];
(第 2 项是通过 Interface Builder 设置的,这是该标题的来源,只是为了测试IB 标题也可以工作——除了第一个)
我有一种感觉,这是将 UITabController 添加到项目并将现有视图拖到第一个位置的奇怪结果,但不知道如何修复它。
这是 Interface Builder 中的视图:
将第一个位置的 ViewController 移动到第二个位置会产生您期望的结果 -第二个位置变为空白,第一个位置设置为“Test1”,这意味着仅第一个位置并不有趣。
I have a UITabBarController in which the first UITabBarItem title is not getting displayed. I have it set in Interface Builder and have tried to set it programmatically, but the title area stays blank.
[[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"Test1"];
[[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"Test2"];
(The Item 2 is set through Interface Builder, which is where that title is coming from, just to test that the IB titles are working as well -- except for the first one)
I have a feeling this is the odd result of adding the UITabController to the project and dragging the existing view into the first spot, but don't know how to fix it.
Here's the view in Interface Builder:
Moving the ViewController that's in the first spot to the second spot yields the result you'd expect -- the second spot becomes blank and the first gets set with "Test1", meaning it's not something funny with just the first spot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需转到视图控制器的 .m 文件中的 init 方法,然后为了设置选项卡栏项目的标题,请使用:
并设置其图像,请使用:
Just go to your init method in your view controller's .m file and in order to set the tab bar item's title use:
and for setting its image, use:
在第一个视图的视图控制器中输入
[self setTitle:@"Title"]
,而不是通过视图控制器数组声明它。虽然不知道出了什么问题,但我不得不这样做一次type
[self setTitle:@"Title"]
in your viewcontroller for the first view instead of declaring it through the viewcontrollers array. don't know whats wrong though, but I had to do this once