3

I have a UIScrollView with pagingEnabled set to YES. some of other configs are:

self.pagingEnabled = NO;
self.directionalLockEnabled = YES;
self.scrollsToTop = NO;
self.showsHorizontalScrollIndicator = NO;
self.showsVerticalScrollIndicator = NO;
self.bounces = NO;

With the default paging config, when I drag the scroll view and release the view in a middle point between two pages. For the case the scrolled distance is more than 50% of a page, then it will auto scroll to the next page. For the case the scrolled distance is less than 50% of a page, it will not.

But I would like to achieve that as long as there is a scrolled distance, no matter it is more than 50% or not, when releasing the view, it auto scrolls to the next page.

I tried to use the delegate:

scrollViewWillEndDragging:withVelocity:targetContentOffset:

and set targetContentOffset to next page when it's called:

targetContentOffset->x = (next page's x)

It won't work, it still uses the 50% threshold. It works only if I set pagingEnabled to NO. But I need pagingEnabled to be YES so the other experience is not changed.

Any idea on why changing targetContentOffset doesn't work? Thanks!

mlin956
  • 345
  • 1
  • 5
  • 13

0 Answers0