1

I want to add UITabBarItem in programmatically in iOS.

In interface Builder,we can easily choose with Identifier for Search,Favourites,Recent Tabs,etc..

I would like to know how can i add these Identifier type in programatically?

Fire Fist
  • 7,032
  • 12
  • 63
  • 109

2 Answers2

4

You add it as a UIViewController's property? You create a UITabBarItem

UITabBarItem *localTabBarItem = [[UITabBarItem alloc]                     initWithTitle:@"Date" image:clockIcon tag:0];

And then set UIViewController's property

[viewController setTabBarItem:localTabBarItem];

Here is a huge pack of TabBar images http://www.axialis.com/objects/ip_icon_09.shtml

Nikita Pestrov
  • 5,876
  • 4
  • 31
  • 66
3
UITabBarItem *barItem = [[UITabBarItem] alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:0];
self.tabBarItem = [barItem autorelease]; //of not using ARC

The predefined system bar items are:

UITabBarSystemItemMore,
UITabBarSystemItemFavorites,
UITabBarSystemItemFeatured,
UITabBarSystemItemTopRated,
UITabBarSystemItemRecents,
UITabBarSystemItemContacts,
UITabBarSystemItemHistory,
UITabBarSystemItemBookmarks,
UITabBarSystemItemSearch,
UITabBarSystemItemDownloads,
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed
graver
  • 15,183
  • 4
  • 46
  • 62