Uicollectionview 单元格未加载二进制数据
Uicollectionview cell not loading binary data
我正在尝试在 uicollectionview imageview 单元格上加载核心数据二进制图像。当我转到集合视图控制器时,我在 theIssues.reloadData() 处收到错误消息 "Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"。如果我评论说屏幕是黑色的。
class theCollection: UICollectionViewCell {
var backButton = UIButton()
@IBOutlet var dx : UIImageView!
}
class collectionVIEW: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{
var users = [Item]()
@IBOutlet var theIssues: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
users = AppDelegate.cdHandler.fetchObject()
theIssues.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return users.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! theCollection
if let imageData = users[indexPath.row].image {
let coredataLoadedimage = UIImage(data: imageData)
cell.dx.image = coredataLoadedimage
//
}
return cell
}
}
我只想获取二进制数据并显示在集合视图单元格图像视图上。
您必须在使用前向 collectionview 注册 theCollectionCell。如果你因为应用程序崩溃而没有注册它。
我正在尝试在 uicollectionview imageview 单元格上加载核心数据二进制图像。当我转到集合视图控制器时,我在 theIssues.reloadData() 处收到错误消息 "Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"。如果我评论说屏幕是黑色的。
class theCollection: UICollectionViewCell {
var backButton = UIButton()
@IBOutlet var dx : UIImageView!
}
class collectionVIEW: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{
var users = [Item]()
@IBOutlet var theIssues: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
users = AppDelegate.cdHandler.fetchObject()
theIssues.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return users.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! theCollection
if let imageData = users[indexPath.row].image {
let coredataLoadedimage = UIImage(data: imageData)
cell.dx.image = coredataLoadedimage
//
}
return cell
}
}
我只想获取二进制数据并显示在集合视图单元格图像视图上。
您必须在使用前向 collectionview 注册 theCollectionCell。如果你因为应用程序崩溃而没有注册它。