Skip to content

Instantly share code, notes, and snippets.

@andatta
Created September 2, 2016 14:49
Show Gist options
  • Save andatta/fc0d78732e50ccb38e84d488eda30fd9 to your computer and use it in GitHub Desktop.
Save andatta/fc0d78732e50ccb38e84d488eda30fd9 to your computer and use it in GitHub Desktop.
/*code snippet shows how we can delete items from collection view without reloading it
the below function is attcahed as selector to a button embedded in collection view cell*/
func removeItem(sender : UIButton){
if let collectionViewCell = sender.superview?.superview as? UICollectionViewCell{
if let indexPath = self.docsCollectionView.indexPathForCell(collectionViewCell){
self.items.removeAtIndex(indexPath.row)
self.collectionView.deleteItemsAtIndexPaths([indexPath])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment