From a2504d8cda7b3c5ec21cf8a319d2a7600d2ae5c9 Mon Sep 17 00:00:00 2001 From: Junjian Lin <> Date: Mon, 4 Mar 2019 11:28:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20:=20FlattenedProvider=20=20misplace?= =?UTF-8?q?=EF=BC=8Ce.g.=20110=20meybe=201-1-0=20or=2011-0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Provider/FlattenedProvider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Provider/FlattenedProvider.swift b/Sources/Provider/FlattenedProvider.swift index a5d36f4..e373828 100644 --- a/Sources/Provider/FlattenedProvider.swift +++ b/Sources/Provider/FlattenedProvider.swift @@ -70,7 +70,7 @@ struct FlattenedProvider: ItemProvider { func identifier(at: Int) -> String { let (sectionIndex, item) = indexPath(at) if let sectionData = childSections[sectionIndex].sectionData { - return provider.identifier(at: sectionIndex) + sectionData.identifier(at: item) + return provider.identifier(at: sectionIndex) + "-" + sectionData.identifier(at: item) } else { return provider.identifier(at: sectionIndex) } From e9a429b9fe8e72848c9ba20c70da7dc74a228487 Mon Sep 17 00:00:00 2001 From: dishcool Date: Tue, 2 Aug 2022 11:13:29 +0800 Subject: [PATCH 2/2] Update CollectionReuseViewManager.swift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: when CollectionView goto Reuse pool,need to set its provider = nil,otherwise there may be two collectionView have the same provider,and maybe will crash later. Fix:当CollectionView进入复用池,需要重置provider,避免出现 多个collectionView 持有同个provider对象,导致数据更新不同步,进而未同步的collectionView中flattenProvider的childSections范围错误导致越界崩溃 --- Sources/Other/CollectionReuseViewManager.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Other/CollectionReuseViewManager.swift b/Sources/Other/CollectionReuseViewManager.swift index a337a8e..1ee6675 100644 --- a/Sources/Other/CollectionReuseViewManager.swift +++ b/Sources/Other/CollectionReuseViewManager.swift @@ -40,6 +40,9 @@ public class CollectionReuseViewManager: NSObject { } else { reusableViews[identifier] = [view] } + if let collectionView = view as? CollectionView { + collectionView.provider = nil + } if let cleanupTimer = cleanupTimer { cleanupTimer.fireDate = Date().addingTimeInterval(lifeSpan) } else {