licroa 2020-01-08 18:35 采纳率: 0%
浏览 530

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)

希望指教,谢谢

  • 写回答

2条回答 默认 最新

  • zqbnqsdsmd 2020-01-09 00:14
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler