【问题标题】:How to programmatically add UITabBarItem's Identifier type in iOS?如何以编程方式在 iOS 中添加 UITabBarItem 的 Identifier 类型?
【发布时间】:2012-04-21 01:42:15
【问题描述】:

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

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

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

【问题讨论】:

    标签: objective-c ios


    【解决方案1】:

    您将它添加为 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

    【讨论】:

    • 如何在 oneViewController 中添加第二个 BarButton?感谢您的回答。
    • 第二栏按钮是什么意思?第二个标签?
    • 如果我是对的,你只需创建一个 tabbarcontroller 并按正确的顺序给它一个 viewcontroller 数组 UITabBarController *mvc = [[UITabBarController alloc]init]; mvc.viewControllers = [NSArray arrayWithObjects:firstVC,secondVC,thirdVC,nil];
    • 是 OneViewController 中的第二个 tabBarItem。
    【解决方案2】:
    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
    

    【讨论】:

      猜你喜欢
      • 2014-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多