Last active
September 24, 2015 14:40
-
-
Save benvium/3888e1b21df0cb852c0a to your computer and use it in GitHub Desktop.
Which UICollectionViewCell will be visible once scrolling finishes? Below assumes a horizontally-oriented UICollectionView.
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
| - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView | |
| withVelocity:(CGPoint)velocity | |
| targetContentOffset:(CGPoint *)targetContentOffset { | |
| CGPoint point = *targetContentOffset; | |
| // Get point in the Center of the view | |
| CGPoint centerPoint = CGPointMake(point.x + CGRectGetWidth(scrollView.bounds) / 2, point.y); | |
| NSIndexPath *path = [self.collectionView indexPathForItemAtPoint:centerPoint]; | |
| if (path) { | |
| NSDate *date = [self indexPathToDate:path]; // My app happens to convert indexPath to date. Yours probably doesn't | |
| DDLogWarn(@"End of scroll is: %@", [self.longDateFormatter stringFromDate:date]); // temp | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment