我试图从collectionviewon didSelect方法中删除一个单元格.
删除数据效果很好.
但是我得到了这个:
原因:'无效更新:无效的节数.更新(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))
}
Run Code Online (Sandbox Code Playgroud)
和numberOfSectionsInCollectionViewfunc:
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
}
}
Run Code Online (Sandbox Code Playgroud)
我只是想重新加载一些部分.我应该添加什么?