
NSInternalinconsistencyException',reason: 'attempt to register a cell class which is not a subclass of UICollectionVIEwCell ((null))
但我想我正在注册这个单元格:
> VIEwDIDLoad:
overrIDe func vIEwDIDLoad(){ super.vIEwDIDLoad() self.collectionVIEw.registerClass(NSClassFromString("CollectionCell"),forCellWithReuseIDentifIEr:"CELL")} > cellForItemAtIndexPath:
func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionVIEwCell{ var cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("CELL",forIndexPath: indexPath) as CollectionCell cell.TitleLabel.text="cellText" return cell} 和细胞类:
class CollectionCell: UICollectionVIEwCell { @IBOutlet var TitleLabel : UILabel init(coder aDecoder: NSCoder!) { super.init(coder: aDecoder) } } 任何帮助赞赏
解决方法 您需要将Swift样式的UICollectionVIEwCell子类传递给registerClass:self.collectionVIEw.registerClass(CollectionCell.self,forCellWithReuseIDentifIEr:"CELL")总结
以上是内存溢出为你收集整理的ios – 使用Swift的UICollectionView错误全部内容,希望文章能够帮你解决ios – 使用Swift的UICollectionView错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)