dequeReusableCell CollectionView Signal Sigbart

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • dequeReusableCell CollectionView Signal Sigbart

    Hallo,

    wie in meiner Überschrift schon steht habe ich ein Problem und zwar wollte ich meiner CollectionView noch einen Section Header hinzugefügt.
    Doch aus irgendeinem Grund failed die App jedes mal durch einen Signal Sigbart. Habe bereits alle Outlet Verbindungen überprüft und auch ob ich alles richtig geschrieben habe doch es scheint alles richtig zu sein.

    Hat jemand von euch eine Idee was ich noch machen könnte um dem Problem auf die Schliche zu kommen oder kennt sogar eine Lösung ?

    Quellcode

    1. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    2. if indexPath.section == 0 {
    3. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "HeaderCell", for: indexPath) as! HeaderCollectionViewCell
    4. return cell
    5. } else {
    6. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "PhotoCell", for: indexPath) as! PhotoCell
    7. let image = images[indexPath.item]
    8. cell.imageView.image = image
    9. cell.imageView.contentMode = .scaleAspectFill
    10. return cell
    11. }
    12. }
    13. }
    Alles anzeigen
  • Und hast du auch geprüft, ob deine Cells die richtige Klasse gesetzt haben?

    C-Quellcode

    1. if indexPath.section == 0 {
    2. guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "HeaderCell", for: indexPath) as? HeaderCollection else {
    3. fatalError("Could not dequeue cell as HeaderCollection")
    4. }
    5. return cell
    6. } else {
    7. guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "PhotoCell", for: indexPath) as? PhotoCell {
    8. fatalError("Could not dequeue cell as PhotoCell")
    9. }
    10. let image = images[indexPath.item]
    11. cell.imageView.image = image
    12. cell.imageView.contentMode = .scaleAspectFill
    13. return cell
    14. }
    Alles anzeigen