将 UIToolbar 添加到 UICollectionView header?

Add UIToolbar to UICollectionView header?

在我的情节提要中,我已将 UIToolBar 添加到我的 CollectionView 的 Header 中,如下所示:

我通过选择 header 框部分创建了 header:

但是,当我运行这个的时候,工具栏根本就没有出现。

我收到标题为 "Unsupported Configurations: Title set but using a system identifier (these attributes are mutually exclusive; the Title will be ignored)"

的警告

我做错了什么?

您不能在 collection 视图 header 中添加工具栏。相反,尝试降低 collection 视图并将工具栏放在 collection 视图的顶部。

希望对您有所帮助

您将需要使用 UIViewController 并为 collectionView 添加委托,然后您将能够调整 collectionView 的大小并在视图中放置一个 UIToolBar。

像这样:

@interface MyViewController : UIViewController<UICollectionViewDelegate,UICollectionViewDataSource>

Swift:

class MyViewController: UIViewController, FirstProtocol, SecondProtocol {
}