5
votes

I want UIScrollView to always scroll back to the specific point. I've achieved it by writing:

   - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset 
{
    (*targetContentOffset).x = 0.0f;
}

it works pretty fine with one exception. When I scroll far enough and reach the end of the view (bouncing starts then) and pull my finger up, the view just scrolls smoothly with deceleration a little back, stops and then jumps (without animation) where I set it. It doesn't happen as long as I don't scroll to the end of the scroll view.

Here's how I init UIScrollView

  scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 284, frame.size.height)];
  scrollView.backgroundColor = [UIColor clearColor];
  scrollView.delegate = self;

  [scrollView setContentSize:CGSizeMake(285,frame.size.height)];
  [self addSubview:scrollView];

  UIEdgeInsets inset = scrollView.contentInset;
  inset.left = 60;
  inset.right = 60;
  [scrollView setContentInset:inset];
2

2 Answers

0
votes

The bouncing effect is a default behavior when you are reaching the boundaries of the content of scrollview you can turn it off by setting the bounces property to NO:

yourscrollView.bounces = NO;

I believe this is only the issue you are facing here.

0
votes

6 years later and still this conflict between the bounces animation and the targetContentOffsetForProposedContentOffset method...