I am creating custom paging for my UICollectionView. I want some of the cells at the bottom to hang from the edge of the screen, however, with regular swapping, scrolling to the next page means that if half of the cell at the bottom of the page is displayed, it will only show the other half - on the next page. I want the cells to hang on the end, but stop paging so that the cells hanging from the screen are clear.
So, to do this, I tried the function - (void) scrollViewWillEndDragging: (UIScrollView *) scrollView withVelocity: (CGPoint) velocity targetContentOffset: (inout CGPoint *) targetContentOffset
If I drag a second or two, it sees the work as expected, however I am trying to emulate a โclickโ that works so well when paging is turned on. When I output my UICollectionView, it goes to targetContentOffset, not the animation.
How to 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; }
source share