Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[ASPagerNode] Fix crash in example reload by nilling-out currentIndexPath after usage. #1418

Merged
merged 1 commit into from
Mar 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions AsyncDisplayKit/ASPagerFlowLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ - (void)invalidateLayout
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset
{
if (self.currentIndexPath) {
return [self _targetContentOffsetForItemAtIndexPath:self.currentIndexPath
proposedContentOffset:proposedContentOffset];
CGPoint contentOffset = [self _targetContentOffsetForItemAtIndexPath:self.currentIndexPath
proposedContentOffset:proposedContentOffset];
self.currentIndexPath = nil;
return contentOffset;
}

return [super targetContentOffsetForProposedContentOffset:proposedContentOffset];
}

- (CGPoint)_targetContentOffsetForItemAtIndexPath:(NSIndexPath *)indexPath proposedContentOffset:(CGPoint)proposedContentOffset
{
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:self.currentIndexPath];
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
CGFloat xOffset = (self.collectionView.bounds.size.width - attributes.frame.size.width) / 2;
return CGPointMake(attributes.frame.origin.x - xOffset, proposedContentOffset.y);
}
Expand All @@ -60,4 +62,4 @@ - (CGRect)_visibleRect
return visibleRect;
}

@end
@end