我制作并实现了一个集合视图控制器,现在我想添加一个底部工具栏用于导航。在Collection View Controller的Simulated Metrics选项卡下,我启用了底部工具栏,它显示在故事板中,我可以编辑它并与之交互。
当我在iPad模拟器中运行应用程序时,底部工具栏不会出现。是否有一些我错过的设置导致它显示在故事板而不是应用程序中?
任何建议都将不胜感激。
答案 0 :(得分:4)
您可以在UINavigationController中嵌入UIViewController。在Storyboard中,将Bottom Bar的Simulated Metrics设置为UINavigationController上的Toolbar选项之一。然后,您将注意到UICollectionViewController底部的工具栏。
我使用Xcode 6.3.2完成了这项工作。
答案 1 :(得分: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];