Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView with section headers like a UITableView

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.

like image 480
emm Avatar asked Jan 03 '14 18:01

emm


People also ask

What is the difference between Uitableview and UICollectionView?

Tableiw is a simple list, which displays single-dimensional rows of data. It's smooth because of cell reuse and other magic. 2. UICollectionView is the model for displaying multidimensional data .

How to add section header in CollectionView Swift?

Connecting the Section Header to Data swift in an additional editor pane and Control-drag from the label in the header view over to the file and name the outlet titleLabel. It will add the following code: class FlickrPhotoHeaderView: UICollectionReusableView { @IBOutlet weak var titleLabel: UILabel! }


1 Answers

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

  2. Implement collectionView:viewForSupplementaryElementOfKind method.

see This Link

like image 135
david72 Avatar answered Oct 14 '22 16:10

david72