JoniVR / VerticalCardSwiper

A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.
MIT License
1.39k stars 100 forks source link

[Bug] [UICollectionView] Invalid update: invalid number of items in section 0. #62

Closed caosuyang closed 4 years ago

caosuyang commented 4 years ago

[28933:533995] [UICollectionView] Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (20) must be equal to the number of items contained in that section before the update (20), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out). - will perform reloadData. UICollectionView instance: <VerticalCardSwiper.VerticalCardSwiperView: 0x7f966c912000; baseClass = UICollectionView; frame = (0 0; 414 482.333); clipsToBounds = YES; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x6000016ca5b0>; layer = <CALayer: 0x600001888ac0>; contentOffset: {-20, 3921.3333333333335}; contentSize: {374, 4361.3793103448279}; adjustedContentInset: {40, 20, 90, 20}; layout: <VerticalCardSwiper.VerticalCardSwiperFlowLayout: 0x7f966c42d390>; dataSource: <VerticalCardSwiper.VerticalCardSwiper: 0x7f966c452760; frame = (0 0; 414 482.333); layer = <CALayer: 0x600001888900>>>; currentUpdate: [UICollectionViewUpdate - 0x7f966c48e5c0: old:<UICollectionViewData: 0x6000021a5880> new<UICollectionViewData: 0x6000021216c0> items:<( "D(0,18)" )>]

JoniVR commented 4 years ago

If you swipe away an item, you need to delete it from your datasource too. Search this issue on stackoverflow. It happens on a collectionview too. Also, check the example code. I'm assuming that's what's going wrong. Unless you provide me with more details.

JoniVR commented 4 years ago

Hi @caosuyang Did you resolve the issue?