【问题标题】:Is there a way to enable the bottom toolbar in a Collection View Controller?有没有办法在集合视图控制器中启用底部工具栏?
【发布时间】:2013-03-26 12:00:24
【问题描述】:

我制作并实现了一个集合视图控制器,现在我希望添加一个底部工具栏用于导航。在 Collection View Controller 的 Simulated Metrics 选项卡下,我启用了底部工具栏,它显示在故事板中,我可以对其进行编辑和交互。

当我在 iPad 模拟器中运行应用程序时,底部工具栏没有出现。是否有一些我缺少的设置导致它显示在情节提要中而不是应用程序中?

任何建议将不胜感激。

【问题讨论】:

  • 离开 UICollectionViewController。在 UIViewController 中使用 UICollectionView。
  • 使用 UICollectionViewController 允许您使用布局到布局的过渡 (iOS 7)。

标签: xcode ipad uitoolbar uicollectionview


【解决方案1】:

您可以将 UIViewController 嵌入到 UINavigationController 中。在情节提要中,将底部栏的模拟指标设置为 UINavigationController 上的工具栏选项之一。然后您会注意到 UICollectionViewController 底部的工具栏。

我使用 Xcode 6.3.2 完成了这项工作。

【讨论】:

    【解决方案2】:

    我在 Interface Builder 中遇到了同样的问题。

    不过,以编程方式添加工具栏可以正常工作:

    // viewWillAppear:
    
    // set up toolbar
    UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height-44, self.view.bounds.size.width, 44)];
    toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
    [self.view addSubview:toolbar];
    
    // instantiate spacer, middleItem
    toolbar.items = @[spacer, middleItem, spacer];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-20
      相关资源
      最近更新 更多