How to set title with UITabbarsystemitem

I just wanted to know how i can set a title of a tab bar item using UITabBarSystemItem ?

What i did :

self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:0];

So to change the title by default instead of "Featured" (because of UITabBarSystemItemFeatured object), I wrote :

self.tabBarItem.title = @"Actu";

So in my mind i should have "Actu" as title instead of "Featured".

But it changes nothing, the title keeps being "Featured" (default title).

I also tried :

[[self.tabBarController.tabBar.items objectAtIndex:0] setTitle:NSLocalizedString(@"Actu", @"Actu")];

(because this tabbaritem is at index 0), but nothing changes.

Or maybe such a modification is not possible using UITabBarSystemItem objects ?

I hope this is well enough explained :/

PS : Sorry for my english and anything else wrong, 1st post ever… :/


When a UITabBarItem is initalized using initWithTabBarSystemItem:tag: you cannot change the image or title properties later on.

Source: iOS Development Documentation


你可以使用KVC。

[self.tabBarItem.setValue("YourTitle", forKey: "internalTitle")];


You already wrote that:

… such a modification is not possible using UITabBarSystemItem objects…

Those have title and image properties set to nil , so they have these values stored in some internal private properties.

Also the docs say:

-initWithTabBarSystemItem:tag:
The title and image properties of the returned item cannot be changed later.

链接地址: http://www.djcxy.com/p/12892.html

上一篇: 使用箭头键遍历有内容的段落

下一篇: 如何使用UITabbarsystemitem设置标题