I am creating custom paging for my UICollectionView. I want some of the cells at the bottom to hang off of the edge of the screen, however, with regular paging, scrolling to the next page means that if half of the cell at the bottom of the page was showing, it will only show the other half on the next page. I want to let the cells hang off of the end, but stop the paging so that the cells hanging off of the screen are in clear view.
So, to do this I overrode the function - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
If I drag for a second or two, it sees to work as expected, however, I am trying to emulate the "flick" that works so well when paging is enabled. When I flick my UICollectionView, it jumps to the targetContentOffset, rather than animates to it.
How do I prevent this?
Here is my code:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
if(targetContentOffset->y < 400) {
targetContentOffset->y = 0;
return;
}
int baseCheck = 400;
while(baseCheck <= 10000) {
if(targetContentOffset->y > baseCheck && targetContentOffset->y < baseCheck + 800) {
targetContentOffset->y = (baseCheck + 340);
return;
}
baseCheck += 800;
}
targetContentOffset->y = 0;
}