惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
The Cloudflare Blog
量子位
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
D
DataBreaches.Net
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
U
Unit 42
博客园 - 聂微东
有赞技术团队
有赞技术团队
A
About on SuperTechFans

Objective-C

oc Swift 调用不同 macos 版本的 同一 header 的接口. 算应急, objective-c 有什么书推荐吗? iOS/Objective-C - NSMutableDictionary 撑爆了内存?
collectionview 插入数据崩溃
axdz · 2020-01-08 · via Objective-C

collectionview 插入数据崩溃了,代码如下

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.numberOfItems(inSection: 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).'

网上查了一下,https://stackoverflow.com/questions/19199985/invalid-update-invalid-number-of-items-on-uicollectionview,用了第二个高票答案,但没有用。 第一个高票答案没看懂,大神指点一下,不知道有没有其它方法