Nil out currentIndexPath after usage to prevent ASPagerFlowLayout crashes

This commit is contained in:
Levi McCallum
2016-03-23 17:55:25 -07:00
parent 505d4ffb5d
commit f760c8460a

View File

@@ -25,8 +25,10 @@
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset
{
if (self.currentIndexPath) {
return [self _targetContentOffsetForItemAtIndexPath:self.currentIndexPath
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);
}