Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a UIScrollView at a specific point?

How do you stop a UIScrollView at specific point? That is, set the final position of the UIScrollView after user interaction?

Specifically, how can you set intervals along a horizontal UIScrollView, so that the it will only stop at these points?

I hope what I have said is clear enough.

like image 418
Jesse Head Avatar asked Jan 25 '12 12:01

Jesse Head


1 Answers

to achieve this u need to enable the paging of the scrollview

For example:

[scrollView setContentSize:CGSizeMake(640, 161)];
[scrollView setPagingEnabled:YES];

here, width of scrollview is 640 (twice of width of iphone screen), if paging is enabled it will divide it equally depending on the width. So as we scroll to this position it will stop at the particular offset.

like image 181
vishy Avatar answered Nov 04 '22 06:11

vishy