I have UICollectionViewcontained in UIViewControllerwhich uses horizontal UICollectionViewFlowLayout. I also use the prototype cell created in mine UIStoryboard. I want to create custom paging, so I use - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset.
The problem is that every time I try to get the indexPathcorresponding targetContentOffset (the point in the scroll list where the scroll stops), the collection view returns zero, even if the point is clearly inside the viewSize collection.
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
NSIndexPath *indexPath = [_collectionView indexPathForItemAtPoint:(*targetContentOffset)];
}
What am I doing wrong?
source
share