Mam UICollectlectView, który ma nagłówków sekcji, ale nie sekcji stopki. W związku z tym nie mam zdefiniowanego widoku stopki. Apple's documentation stwierdza, że You must not return nil from this method.
Co powrócić z kolekcjiView (_: viewForSupplementaryElementOfKind: at :), jeśli nie chcesz niczego zwracać?
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
switch kind {
case UICollectionElementKindSectionHeader:
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind,
withReuseIdentifier: "MyHeaderView",
for: indexPath) as! MyHeaderView
switch indexPath.section
{
case 0:
headerView.label_title.text = "SOME HEADER"
case 1:
headerView.label_title.text = "ANOTHER HEADER"
default:
headerView.label_title.text = "UNKNOWN HEADER"
}
return headerView
default:
assert(false, "Unexpected element kind") // Not a good idea either
}
return nil // NOPE, not allowed
}
powrót pusty UICollectionReusableView() jak to –