swift invalid number of items in section 0

collection view报错
代码如下:
let selectIndex = self.photoData.seletedAssetArray.index(of: self.previewPhotoArray[currentIndex])
if selectIndex != nil{
self.rightButton.asyncSetImage(UIImage.zyCreateImageWithView(view: ZYPhotoNavigationViewController.zyGetSelectNuberView(index: "(selectIndex! + 1)")), for: .selected)
}

        if selectIndex != nil{
            if self.rightButton.isSelected == false {
                let indexPath = IndexPath.init(row: selectIndex!, section: 0)
                self.photoData.seletedAssetArray.remove(at: self.photoData.seletedAssetArray.index(of: self.previewPhotoArray[currentIndex])!)
                thumbnailCollectionView.deleteItems(at: [indexPath])
            }else{
                let indexPath = IndexPath.init(row: selectIndex!, section: 0)
                thumbnailCollectionView.insertItems(at: [indexPath])
                thumbnailCollectionView.reloadItems(at: [indexPath])
                thumbnailCollectionViewCellToggeleSelect(indexPath: indexPath)
            }
        }

报错信息:
'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out)

希望指教,谢谢

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问