2

I have a long horizontal UIScrollView and I want to make it stop and bounce in some special cases. Is there a way to do that without changing the content lenght?

EDIT: I don't want it to scroll to a position, I just want it to act as if it hit its boundary somewhere.

david
  • 3,553
  • 4
  • 28
  • 39
  • I think you should read this: http://stackoverflow.com/questions/2234875/programmatically-scroll-a-uiscrollview – Franck May 06 '13 at 08:38
  • You can override the resting location through `scrollViewWillEndDragging:withVelocity:targetContentOffset:` but you can't affect the bouncing afaik. – Mike Weller May 06 '13 at 08:48

2 Answers2

1

You can enable the scroll view to bounce using:

//scroll is an instance of UIScrollView
scroll.alwaysBounceVertical/Horizontal = YES;
Anil
  • 1,028
  • 9
  • 20
  • I am currently stopping the scrolling with scrollViewDidScroll: and then setting scrollView.contentOffset.x. That prevents bouncing :P Is there another way to stop the view from scrolling? – david May 06 '13 at 12:27
  • scrollView.contentSize = CGSizeMake(scrollView.frame.size.width,scrollView.frame.size.height); – Anil May 06 '13 at 12:39
0

You can use scrollRectToVisible:animated: method if you want to scroll to a particular position

Walid Hossain
  • 2,724
  • 2
  • 28
  • 39