Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension ViewController: UICollectionViewDataSource {
- // ....
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MarksCollectionViewCell.identifier, for: indexPath) as! MarksCollectionViewCell
- let userMarks = students[indexPath.section].marks[subject(atColumn: indexPath.item)] ?? 0
- cell.setupCell(userMarks: userMarks, outOf: Consts.maximumAllotedMarks)
- return cell
- }
- func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
- let headerViewType: HeaderSupplementaryViewProtocol.Type
- let title: String
- if kind == RowHeaderSupplementaryView.identifier {
- headerViewType = RowHeaderSupplementaryView.self
- title = students[indexPath.section].name
- } else if kind == ColumnHeaderSupplementaryView.identifier {
- headerViewType = ColumnHeaderSupplementaryView.self
- title = subject(atColumn: indexPath.item).title
- } else {
- return UICollectionReusableView()
- }
- let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: headerViewType.identifier, withReuseIdentifier: headerViewType.reuseIdentifier, for: indexPath) as! HeaderSupplementaryView
- headerView.setTitle(title)
- return headerView
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement