Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.
Open
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
12 changes: 7 additions & 5 deletions QBImagePicker/QBAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ - (NSArray *)qb_indexPathsFromIndexesWithSection:(NSUInteger)section

@implementation UICollectionView (Convenience)

- (NSArray *)qb_indexPathsForElementsInRect:(CGRect)rect
- (NSArray *)qb_indexPathsForCellsInRect:(CGRect)rect
{
NSArray *allLayoutAttributes = [self.collectionViewLayout layoutAttributesForElementsInRect:rect];
if (allLayoutAttributes.count == 0) { return nil; }

NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:allLayoutAttributes.count];
for (UICollectionViewLayoutAttributes *layoutAttributes in allLayoutAttributes) {
NSIndexPath *indexPath = layoutAttributes.indexPath;
[indexPaths addObject:indexPath];
if (layoutAttributes.representedElementCategory == UICollectionElementCategoryCell) {
NSIndexPath *indexPath = layoutAttributes.indexPath;
[indexPaths addObject:indexPath];
}
}
return indexPaths;
}
Expand Down Expand Up @@ -307,10 +309,10 @@ - (void)updateCachedAssets
NSMutableArray *removedIndexPaths = [NSMutableArray array];

[self computeDifferenceBetweenRect:self.previousPreheatRect andRect:preheatRect addedHandler:^(CGRect addedRect) {
NSArray *indexPaths = [self.collectionView qb_indexPathsForElementsInRect:addedRect];
NSArray *indexPaths = [self.collectionView qb_indexPathsForCellsInRect:addedRect];
[addedIndexPaths addObjectsFromArray:indexPaths];
} removedHandler:^(CGRect removedRect) {
NSArray *indexPaths = [self.collectionView qb_indexPathsForElementsInRect:removedRect];
NSArray *indexPaths = [self.collectionView qb_indexPathsForCellsInRect:removedRect];
[removedIndexPaths addObjectsFromArray:indexPaths];
}];

Expand Down