Last active
September 15, 2015 08:56
-
-
Save benvium/3fd1381546cc454f4dcc to your computer and use it in GitHub Desktop.
Get the NSIndexPaths for visible rows on a UICollectionView, sorted by row. For some reason [collectionView indexPathsForVisibleItems] returns unsorted items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get visible rows and sort them by row | |
| - (NSArray *)sortedVisibleIndexPaths { | |
| NSArray *visibleItems = [self.collectionView indexPathsForVisibleItems]; | |
| // visible items is NOT SORTED! lol | |
| NSSortDescriptor *rowDescriptor = [[NSSortDescriptor alloc] initWithKey:@"row" ascending:YES]; | |
| NSMutableArray *sortedRows = [[visibleItems sortedArrayUsingDescriptors:@[rowDescriptor]] mutableCopy]; | |
| return sortedRows; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment