Post

Replies

Boosts

Views

Activity

UICollectionView.CellRegistration from custom nib
I'm trying to migrate from old style cell registration collectionView?.register(UINib(nibName: "MyCustomViewCell", bundle: nil), forCellWithReuseIdentifier: MyCustomViewCell.reuseIdentifier) to new UICollectionView.CellRegistration. Currently I always end up with an NSInternalConstistencyException: view reuse identifier in nib (MyCustomViewCell) does not match the identifier used to register the nib (9AA266FF-550D-4A6B-ACCD-4E90B25E6DDC). This is how I do my new style cell registration: let cellRegistration = UICollectionView.CellRegistration<MyCustomViewCell, MyItem>(cellNib: UINib(nibName: "MyCustomViewCell", bundle: nil)) { cell, indexPath, item in             cell.configure(with: item)         } If I use a default cell to test the whole collectionView setup everything works as expected (I see my cells etc.):         let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, MyItem> { cell, indexPath, item in           // Populate the cell with our item description.             var contentConfiguration = cell.defaultContentConfiguration()             contentConfiguration.text = item.title         } My custom cell has a reuseIdentifier both in the nib file as well as in the class definition eg.: class MyCustomViewCell: UICollectionViewCell {     static let reuseIdentifier = "MyCustomViewCell" Any hints?
3
0
2.3k
Sep ’21