我在 Storyboard 中使用自定义 CollectionViewCell。
当我启动应用程序时,我收到以下消息:
无法将“UICollectionViewCell”类型的值转换为
TestProject.CollectionViewCell。
Xcode 中 CollectionViewController 的模板在 viewDidLoad 中附带了这行代码,它会更改故事板中的规范。
// Register cell classes
self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
只需删除该行即可。
在较旧的 Swift 版本中,该行是:
// Register cell classes
self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)