我在故事板中有一个UICollectionViewController,它已链接到一个名为XCollectionViewController.
swift的文件,该文件是UICollectionViewController的子类.
我的代码如下:
super.viewDidLoad() // Register cell classes self.collectionView!.registerClass(UICollectionViewCell.self,forCellWithReuseIdentifier: reuseIdentifier) } override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { //#warning Incomplete method implementation -- Return the number of sections return 4 } override func collectionView(collectionView: UICollectionView,numberOfItemsInSection section: Int) -> Int { //#warning Incomplete method implementation -- Return the number of items in the section return 10 } override func collectionView(collectionView: UICollectionView,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier,forIndexPath: indexPath) as! UICollectionViewCell // Configure the cell return cell }
在运行中,我可以看到CollectionView的背景,但不是我应该看到的40个单元格.怎么了?
只需在viewDidLoad方法中删除此行即可显示您的40个单元格.
self.collectionView!.registerClass(UICollectionViewCell.self,forCellWithReuseIdentifier: reuseIdentifier)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。