UICollectionView horizontal scrolling, deleting last item, animation not working

前端 未结 6 426
我在风中等你
我在风中等你 2021-02-02 00:53

I have a UICollectionView. It scrolls horizontally, has only a single row of items, and behaves like a paging UIScrollView. I\'m making something along the lines of the Safari t

6条回答
  •  温柔的废话
    2021-02-02 01:32

    A cheap solution is to add another 0px cell as the last cell and never remove it.

    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        if indexPath.row < collectibles.count - 1 { // dont delete the last one. just because the animation isn't working
            collectibles.removeAtIndex(indexPath.row)
            collectionView.deleteItemsAtIndexPaths([indexPath])
        }
    }
    

提交回复
热议问题