1

我想在 iOS 中以编程方式添加 UITabBarItem。

在界面生成器中,我们可以轻松地选择搜索标识符、收藏夹、最近标签等。

我想知道如何以编程方式添加这些标识符类型?

4

2 回答 2

4

您将它添加为 UIViewController 的属性?你创建一个UITabBarItem

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

然后设置 UIViewController 的属性

[viewController setTabBarItem:localTabBarItem];

这是一大包 TabBar 图像http://www.axis.com/objects/ip_icon_09.shtml

于 2012-04-20T17:26:11.310 回答
3
UITabBarItem *barItem = [[UITabBarItem] alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:0];
self.tabBarItem = [barItem autorelease]; //of not using ARC

预定义的系统栏项目是:

UITabBarSystemItemMore,
UITabBarSystemItemFavorites,
UITabBarSystemItemFeatured,
UITabBarSystemItemTopRated,
UITabBarSystemItemRecents,
UITabBarSystemItemContacts,
UITabBarSystemItemHistory,
UITabBarSystemItemBookmarks,
UITabBarSystemItemSearch,
UITabBarSystemItemDownloads,
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed
于 2012-04-20T17:42:15.747 回答