0
有它加载自定义collectionViewCell
每7个细胞UICollectionView
。这个问题是它从主数组的内容中消失了。我如何添加细胞,而不使用indexPath
(即如果mainArray.count == 17只15显示,因为indexPaths 具有为
customCollectionViewCells
被指定加载。)
我不希望用部分。我想知道这是否是一种加载这些单元而不会从主要内容中删除的方法?
我已经试过
func collectionView(_ collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
let counter == 0;
if (index == 7 || index == 14) {
counter = customCellsArray.count
}
else{
counter = mainArray.count
}
return counter;
}
'致命错误阵列索引超出range'(上mainArray)的每个的CollectionView到达最后信元时被抛出。 –
好吧,你需要调试它。什么是指数?阵列的大小是多少?你如何计算指数?那里可能有一个错误。在计算它的地方设置一个断点,看看发生了什么。或者发布更多的代码,或者考虑用现在的代码来开启一个新的问题。 –