【发布时间】:2012-04-21 01:42:15
【问题描述】:
我想在 iOS 中以编程方式添加 UITabBarItem。
在界面生成器中,我们可以轻松选择搜索标识符、收藏夹、最近标签等。
我想知道如何以编程方式添加这些标识符类型?
【问题讨论】:
标签: objective-c ios
我想在 iOS 中以编程方式添加 UITabBarItem。
在界面生成器中,我们可以轻松选择搜索标识符、收藏夹、最近标签等。
我想知道如何以编程方式添加这些标识符类型?
【问题讨论】:
标签: objective-c ios
您将它添加为 UIViewController 的属性?
你创建一个UITabBarItem
UITabBarItem *localTabBarItem = [[UITabBarItem alloc]
initWithTitle:@"Date" image:clockIcon tag:0];
然后设置UIViewController的属性
[viewController setTabBarItem:localTabBarItem];
这是一大包 TabBar 图片http://www.axialis.com/objects/ip_icon_09.shtml
【讨论】:
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
【讨论】: