I tried to delete a cell from collectionview
on didSelect
method.
Deleting the data is working well.
But I'm getting this:
reason: 'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (1) must be equal to the number of sections contained in the collection view before the update (2), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'
This is delete cell function:
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))
}
and numberOfSectionsInCollectionView
func :
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
}
}
I just want to reload number of sections. What should I add?