
“ https://www.raywenderlich.com/392-uicollectionview-custom-layout-tutorial-pinterest”
创建自定义UICollectionVIEw. (调整细胞高度)
如果我向上滚动,将继续添加单元格,并从上到下滚动以刷新.
运行应用程序并最初生成单元格时没有问题.
但是,刷新或重新排序单元格数时始终存在错误.
错误:
*** Assertion failure in -[UICollectionVIEwData valIDateLayoutInRect:],/buildroot/library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.93.8/UICollectionVIEwData.m:447
*** Terminating app due to uncaught exception ‘NSInternalinconsistencyException’,reason: ‘UICollectionVIEw received layout attributes for a cell with an index path that does not exist :
因此,
“iOS 10 bug: UICollectionView received layout attributes for a cell with an index path that does not exist”
并试图解决错误.
在下面的行
self.artCollectionVIEw.reloadData ()
我尝试添加
self.artCollectionVIEw.collectionVIEwLayout.invalIDateLayout ()
但它没有得到解决.
另外,我不知道在哪里跑
cache.removeAll ()
在prepare()部分.
(PinterestLayout.swift中有一个prepare()函数)
解决错误的正确方法是什么?
解决方法 PinterestLayout.swift中有prepare函数应该是因为它是用于自定义collectionVIEw的唯一布局.在第76行,在PinterestLayout.swift文件中.
尝试
overrIDe public func prepare() { cache.removeAll() if cache.isEmpty { ..... }} 总结 以上是内存溢出为你收集整理的ios – 错误:UICollectionView接收到具有Swift中不存在的索引路径的单元格的布局属性全部内容,希望文章能够帮你解决ios – 错误:UICollectionView接收到具有Swift中不存在的索引路径的单元格的布局属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)