如何在UICollectionView中添加节标题? [英] How do I add a section title in UICollectionView?

查看:146
本文介绍了如何在UICollectionView中添加节标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Collection View中的每个部分都需要一个标签。我试过简单地将标签拖到原型单元格上方的标题空间中,但每次运行应用程序时,标签都不可见。

I need a label above every section in my Collection View. I've tried simply dragging a label into my header space above my prototype cell, but every time I run the app, the label is not visible.

任何帮助?

推荐答案

实施 collectionView:viewForSupplementaryElementOfKind:atIndexPath:并提供包含标签的出列UICollectionElementKindSectionHeader。如果这是流布局,请务必设置 headerReferenceSize ,否则您仍然看不到任何内容。

Implement collectionView:viewForSupplementaryElementOfKind:atIndexPath: and supply a dequeued UICollectionElementKindSectionHeader containing your label. If this is a flow layout, be sure also to set the headerReferenceSize or you still won't see anything.

这篇关于如何在UICollectionView中添加节标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆