且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法为UITabBar设置单独的短标题?

更新时间:2022-10-17 17:46:21

在UITabBar中显示的信息从每个UIViewController的tabBarItem属性查询,类似地,UINavigationBar查询



设置两个不同的标题将像这样工作(从UIViewController内): $ p> self.tabBarItem.title = @TabTitle;
self.navigationItem.title = @NavigationTitle;

您还可以通过这些属性指定其他详细信息,如标签栏图像或后退按钮上的标题。


I'd like to be able to give my views short names for display on the tab bar, and longer (more descriptive) name when the same view is linked to in a table view. The reason is that longer names nudge up against each other on the tab bar. In a table view, there's more horizontal space, so I want to use more descriptive titles there.

Normally, the tab bar's title is set in its view controller with self.title. Is there a way to specifically set the tab bar title, but leave the view controller's self.title alone?

Thanks.

The information that is displayed in a UITabBar is queried from each UIViewController's tabBarItem" property. Similarly, a UINavigationBar queries the UIViewController's navigationItem for information.

Setting two different titles would work like this (from within you UIViewController):

self.tabBarItem.title = @"TabTitle";
self.navigationItem.title = @"NavigationTitle";

You can also specify other details like the tab bar image or the title on the "back button" via these properties.