【发布时间】:2016-08-01 02:05:04
【问题描述】:
我尝试使用didSelect 方法从collectionview 中删除一个单元格。
删除数据效果很好。
但我得到了这个:
原因:'无效更新:无效的节数。的数量 更新 (1) 后集合视图中包含的部分必须是 等于集合视图中包含的部分数 在更新 (2) 之前,加上或减去插入的节数 或已删除(0 插入,0 删除)。'
这是删除单元格功能:
func deleteMovie(cell: MoiveCollectionViewCell) {
var indexPath: NSIndexPath = self.collectionView!.indexPathForCell(cell)!
// remove and reload data
self.collectionView.deleteItemsAtIndexPaths([indexPath])
self.collectionView.reloadSections(NSIndexSet(index: indexPath.section))
}
和numberOfSectionsInCollectionView函数:
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
//number_per_section = 3
if manager.movie_List.count % number_per_section == 0
{
return manager.movie_List.count / number_per_section
}
else {
return manager.movie_List.count / number_per_section + 1
}
}
我只想重新加载部分的数量。我应该添加什么?
【问题讨论】:
标签: swift xcode collectionview