UIScrollView bounces a little after slowdown

I have scrollView with pagingScrollView.pagingEnabled = YES; . After going to the next page, scrollView bounces a little after slowing down, here is my origin.x journal changing with comments:

 2010-11-03 12:53:09.187 app[84864:207] scrollview.bound.origin.x: 713.000000 << deccelerating.. 2010-11-03 12:53:09.199 app[84864:207] scrollview.bound.origin.x: 727.000000 2010-11-03 12:53:09.212 app[84864:207] scrollview.bound.origin.x: 738.000000 2010-11-03 12:53:09.230 app[84864:207] scrollview.bound.origin.x: 747.000000 2010-11-03 12:53:09.248 app[84864:207] scrollview.bound.origin.x: 754.000000 2010-11-03 12:53:09.262 app[84864:207] scrollview.bound.origin.x: 759.000000 2010-11-03 12:53:09.278 app[84864:207] scrollview.bound.origin.x: 763.000000 2010-11-03 12:53:09.295 app[84864:207] scrollview.bound.origin.x: 766.000000 2010-11-03 12:53:09.312 app[84864:207] scrollview.bound.origin.x: 768.000000 <<at this origin.y, should stop deccelerating 2010-11-03 12:53:09.328 app[84864:207] scrollview.bound.origin.x: 769.000000 <<bounce ? 2010-11-03 12:53:09.377 app[84864:207] scrollview.bound.origin.x: 770.000000 <<bounce ? 2010-11-03 12:53:09.378 app[84864:207] scrollview.bound.origin.x: 769.000000 <<bounce ? 2010-11-03 12:53:09.395 app[84864:207] scrollview.bound.origin.x: 768.000000 <<stopped 

How could this happen? The frame width is 768 pixels.

+4
source share
1 answer

I have the same problem. Disabling bouncing does nothing.

UPD:

I still don’t know why this is happening. I checked Apple's PhotoScroller sample, and this thing also happens there. I found this workaround - maybe this is not very good, but it works:

  • I am waiting for this event:

     -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView; 

and then just set the content to the correct position:

 CGFloat pageWidth = pagingScrollView.bounds.size.width; NSInteger curPage = currentPage; if (firstTapPoint.x > lastTapPoint.x) { //NSLog(@"Going prev page"); curPage = (curPage==0)?0:(currentPage-1); }else if(firstTapPoint.x < lastTapPoint.x){ //NSLog(@"Going next page"); curPage = (currentPage==([self imageCount]-1))?currentPage:(currentPage+1); }else if(firstTapPoint.x == lastTapPoint.x) { //NSLog(@"Staying on the same page"); } //NSLog(@"Current page is %d and the next page is %d", currentPage, curPage); CGPoint finalOffset = CGPointMake(pageWidth * curPage, 0); [scrollView setContentOffset:finalOffset animated:YES]; 

Then the scroll view scrolls to the right to the position I specified without any “tail bounces”

+4
source

All Articles