Merge pull request #1418 from levi/patch-10

[ASPagerNode] Nil out currentIndexPath after usage to prevent ASPagerFlowLayout crashes
This commit is contained in:
appleguy
2016-03-23 18:35:05 -07:00

View File

@@ -25,8 +25,10 @@
- (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];
@@ -34,7 +36,7 @@
- (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);
}
@@ -60,4 +62,4 @@
return visibleRect;
}
@end
@end