Skip to content

Commit

Permalink
Ensure a supplementary view is of kind _ASCollectionReusableView befo…
Browse files Browse the repository at this point in the history
…re setting its layoutAttributes
  • Loading branch information
nguyenhuy committed Apr 19, 2017
1 parent 7c86faf commit f39da70
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1118,9 +1118,10 @@ - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(

- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(_ASCollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
{
// Since _ASCollectionReusableView is not available for subclassing, comparing the classes is faster than isKindOfClass:
// This is a safeguard similar to the behavior for cells in -[ASCollectionView collectionView:willDisplayCell:forItemAtIndexPath:]
// It ensures _ASCollectionReusableView receives layoutAttributes and calls applyLayoutAttributes.
if (view.layoutAttributes == nil) {
if (([view class] == [_ASCollectionReusableView class]) && (view.layoutAttributes == nil)) {
view.layoutAttributes = [collectionView layoutAttributesForSupplementaryElementOfKind:elementKind atIndexPath:indexPath];
}

Expand Down

0 comments on commit f39da70

Please sign in to comment.