Could not cast value of type 'UICollectionViewCell'

后端 未结 6 1121
野性不改
野性不改 2021-02-01 12:21

I use a custom CollectionViewCell in my Storyboard. When I start the app I get this message:

Could not cast value of type \'UICollectionViewCell\' to T

6条回答
  •  死守一世寂寞
    2021-02-01 13:13

     self.collectionView!
         .register(MyCollectionViewCell.self, 
                   forCellWithReuseIdentifier: reuseIdentifier
                  )
    

    You don't have to delete this line. You will register your own cell class inherited by UICollectionViewCell.self if you want to register class using code

提交回复
热议问题