import UIKit
import Photos
class GalleryController: UICollectionViewController,
UIImagePickerControllerDelegate,
UINavigationControllerDelegate {
var Receipts = [UIImage?]()
//Number of Views
override func numberOfSections(in collectionView: UICollectionView) -> Int {
print("return1")
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
print("self.receipts.count")
return self.Receipts.count
}
Dieser Code unten nicht, wie es sollte funktioniert und jedes Mal laufe ich die App es mit diesem Fehler kommt --Sammlung Ansicht endet nach cellForItemAtIndex
SmartReceipts[738:137366] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the collection view's data source did not return a valid cell from -collectionView:cellForItemAtIndexPath: for index path {length = 2, path = 0 - 0}' *** First throw call stack: (0x186196364 0x1853dc528 0x186196238 0x186b317f4 0x1901010b0 0x18f6d7124 0x18f6d1de0 0x18f674f00 0x18a1d9998 0x18a1ddb20 0x18a14a36c 0x18a171b90 0x18f66a5c8 0x18613dedc 0x18613b894 0x18613be50 0x18605be58 0x187f08f84 0x18f6db67c 0x104484668 0x185b7856c) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
Jede mögliche Hilfe bei diesem würde sehr geschätzt werden.
Und der Code, die Fixierung benötigt, ist der folgende Code:
func collectionView(_ collectionView: UICollectionView, cellForItemAtindexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "receipt", for: indexPath as IndexPath) as? PhotoCell
cell?.imageView.image = self.Receipts[indexPath.row]
print("Assigned to cell and should come up")
return cell!
}
}
Es ist nun Fehler wie diese error und ich bin nicht sicher, wie es es tut? Weil das Bild an ein Array gesendet wird, aber nicht in der UICollectionViewCell angezeigt wird?
bitte nicht, Ihre Beiträge verwüsten. Sobald Sie einen Beitrag eingereicht haben, haben Sie den Inhalt für die gesamte Stack Overflow-Community lizenziert (unter der CC-by-SA-Lizenz). – Mithrandir