From bb89f70510061646056211b6da8ca07c0f4433ea Mon Sep 17 00:00:00 2001 From: Zhisheng Huang Date: Fri, 14 Feb 2020 15:27:12 -0800 Subject: [PATCH] Fix a bug in IGListBindingSingleSectionController for displayingCell setting Summary: When a section/cell is reloaded, UICollectionView actually calls: 1/ WillDisplay (new cell) 2/ DidEndDisplay (old cell) So if we set `_displayingCell` in willDisplay call, then set it to nil in didEndDisplay, we would just have a nil cell. Thus we need to make sure the cell in `didEndDisplay` match with the previous `_displayCell` to avoid nil-ing ourselves out. Reviewed By: alanzeino Differential Revision: D19906734 fbshipit-source-id: 5217908ae99d488a2af5ff3f90ef8e021774acda --- Source/IGListKit/IGListBindingSingleSectionController.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/IGListKit/IGListBindingSingleSectionController.m b/Source/IGListKit/IGListBindingSingleSectionController.m index bcffa33c..f57bdc55 100644 --- a/Source/IGListKit/IGListBindingSingleSectionController.m +++ b/Source/IGListKit/IGListBindingSingleSectionController.m @@ -72,7 +72,9 @@ - (void)listAdapter:(nonnull IGListAdapter *)listAdapter didEndDisplayingSectionController:(nonnull IGListSectionController *)sectionController cell:(nonnull UICollectionViewCell *)cell atIndex:(NSInteger)index { IGParameterAssert(index == 0); - _displayingCell = nil; + if (cell == _displayingCell) { + _displayingCell = nil; + } } #pragma mark - IGListSectionController Overrides