My UICollectionView:
@IBOutlet weak var mediaProfileCollectionView: UICollectionView!
i add this code in viewDidLoad():
mediaProfileCollectionView.register(UINib(nibName: "MediaProfileCollectionView", bundle: nil), forCellWithReuseIdentifier: "MediaProfileCollectionViewCell")
then i use in:
viewModelProfile.mediaProfileCollectionView
.asObservable()
.bind(to: mediaProfileCollectionView.rx.items(cellIdentifier: "MediaProfileCollectionViewCell", cellType: MediaProfileCollectionViewCell.self)) { (row,data,cell) in
cell.setMediaImage(from: data)
}.disposed(by: disposeBag)
and then i get error message:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'MediaProfileCollectionView'
can someone help me ..
Most likely you want to register xib for the cell and not for the view itself:
mediaProfileCollectionView.register(
UINib(nibName: "MediaProfileCollectionViewCell", bundle: nil),
forCellWithReuseIdentifier: "MediaProfileCollectionViewCell"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.