티스토리 뷰

iOS

[iOS] DiffableDatasource 와 reconfigureItems

Kim_Baechu 2023. 3. 30. 23:27

iOS15에서부터 reconfigureItems를 사용할 수 있습니다.

“To update the contents of existing (including prefetched) cells without replacing them with new cells…”

cell을 update하기 위해서 reloadItems(\\_:)대신 사용합니다.

새로운 셀로 바꾸는 것이 아니기 때문에 퍼포먼스가 더 좋습니다.

“Because this method reconfigures existing cells, the collection view or table view doesn’t call prepareForReuse for each cell dequeued.”

하지만 prepareForReuse가 불리지 않는 다는 점을 주의해야합니다.

reconfigure -> collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item) -> UICollectionView.CellRegistration

 

self-Sizing 셀일 경우, reconfiguring 이후에 셀을 리사이즈합니다.

animatingDifferences로 애니메이션을 결정하게 되는데,

특정한 프로퍼티를 설정할 때 애니메이션을 피하고 싶으면 cell configuration logic에 performWithoutAnimation(\\_:) 를 사용하세요.

댓글
공지사항