1

在我swift应用我使用UICollectionViewController在我旁边显示彼此的一张照片:如何在我的UICollectionView的Section Header中显示图像和标签?

enter image description here

我还增加了收藏的顶视图的头,我做到了通过故事董事会通过检查该选项:

enter image description here

所以,现在我看到,头在我的故事板,我甚至可以把有一些标签:

enter image description here

但我该如何显示任何东西?我尝试将IBOutlet从此标签附加到该视图的主类,但是这会导致我错误地指出Collection reusable view的插座无法直接附加到UICollectionViewcontroller。在这种情况下我能做些什么?

回答

3

要完成此任务,您需要继承UICollectionViewController并将此类指定为您的页眉和页脚。然后在该课程中,您可以创建在故事板中分配的视图的Outlet连接。

子类的UICollectionReusableView:

enter image description here

指定子类的UICollectionViewController头:

Assign subclass to the UICollectionViewController header

拖动的元素在故事板头然后创建IBOutlet连接灰。

Create the IBOutlet connection

相关问题