带有部分标题的 UICollectionView,如 UITableView [英] UICollectionView with section headers like a UITableView

查看:20
本文介绍了带有部分标题的 UICollectionView,如 UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简短的问题,是否有人能够成功地在 CollectionView 中创建和实现部分标题,类似于 TableView 中的标题?我做了很多研究,发现了一些代码片段,但没有任何人成功实现这一点的真实例子.我有照片的 CollectionView,我想要实现的是根据拍摄的月份将它们分组.我已经设法将它们分成这些部分,但我现在所拥有的只是每个部分开头上方的空白标题.我想要做的是在那些当前空白的标题中显示月份.每个部分的字母在显示联系人的表格视图中显示的方式相同.感谢您提前回复.

I have a quick question has anyone been able to successfully create and implement section headers in a CollectionView similar to the headers in a TableView ? I did a lot of research and found snippets of code but no real example from anyone who successfully achieved this. I have a CollectionView of photos, What I am trying to achieve is to group them up in sections depending on the month which they were taken. I have managed to split them up into those sections but all I have now is a blank header right above the start of each section. What I want to do is display the months in those currently blank headers. The same way the letters for each section are displayed in the Tableview that displays the contacts. Thanks for your responses in advance.

推荐答案

  1. 在 Storyboard 中启用部分页眉/页脚视图.

  1. Enable the section header/footer view in Storyboard.

实现 collectionView:viewForSupplementaryElementOfKind 方法.

请参阅此链接

这篇关于带有部分标题的 UICollectionView,如 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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