mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Nil out currentIndexPath after usage to prevent ASPagerFlowLayout crashes
This commit is contained in:
@@ -25,8 +25,10 @@
|
|||||||
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset
|
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset
|
||||||
{
|
{
|
||||||
if (self.currentIndexPath) {
|
if (self.currentIndexPath) {
|
||||||
return [self _targetContentOffsetForItemAtIndexPath:self.currentIndexPath
|
CGPoint contentOffset = [self _targetContentOffsetForItemAtIndexPath:self.currentIndexPath
|
||||||
proposedContentOffset:proposedContentOffset];
|
proposedContentOffset:proposedContentOffset];
|
||||||
|
self.currentIndexPath = nil;
|
||||||
|
return contentOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [super targetContentOffsetForProposedContentOffset:proposedContentOffset];
|
return [super targetContentOffsetForProposedContentOffset:proposedContentOffset];
|
||||||
@@ -34,7 +36,7 @@
|
|||||||
|
|
||||||
- (CGPoint)_targetContentOffsetForItemAtIndexPath:(NSIndexPath *)indexPath proposedContentOffset:(CGPoint)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;
|
CGFloat xOffset = (self.collectionView.bounds.size.width - attributes.frame.size.width) / 2;
|
||||||
return CGPointMake(attributes.frame.origin.x - xOffset, proposedContentOffset.y);
|
return CGPointMake(attributes.frame.origin.x - xOffset, proposedContentOffset.y);
|
||||||
}
|
}
|
||||||
@@ -60,4 +62,4 @@
|
|||||||
return visibleRect;
|
return visibleRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user