Fix setting selectedBackgroundView in collection view (#3131)

This commit is contained in:
Michael Schneider 2017-03-06 07:19:44 -08:00 committed by GitHub
parent 2df392261e
commit d0ad24808b

View File

@ -969,7 +969,6 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
if (_ASCollectionViewCell *asCell = ASDynamicCast(cell, _ASCollectionViewCell)) {
asCell.node = node;
asCell.selectedBackgroundView = node.selectedBackgroundView;
[_rangeController configureContentView:cell.contentView forCellNode:node];
}
@ -991,6 +990,10 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
ASCellNode *cellNode = [cell node];
cellNode.scrollView = collectionView;
// Update the selected background view in collectionView:willDisplayCell:forItemAtIndexPath: otherwise it could be to
// early e.g. if the selectedBackgroundView was set in didLoad()
cell.selectedBackgroundView = cellNode.selectedBackgroundView;
// Under iOS 10+, cells may be removed/re-added to the collection view without
// receiving prepareForReuse/applyLayoutAttributes, as an optimization for e.g.