Вопрос

The image https://www.dropbox.com/s/e7b189mzl168efk/scrollview.png is my scrollview and 4views. What I want is when I pulldown the scrollView it display the views base on the offset. And I want to stop the scroll when it reach to end view. Currently it still continue to scroll.

its like

if(scrollView.contentOffset.y == -155)

then scroll will not continue to scroll but i can still scroll back to the bottom to highlight the view3 or until view1. Please refer on the image.

example code is very helpful.

Это было полезно?

Решение

I don't know if I understand the question, but to stop a scrolling scroll view you can do the following in the delegate of the scroll view:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.y <= -155.0) {
        [scrollView setContentOffset:CGPointMake(0, -155.0) animated:NO];
    }
}

And if you want to scroll to a specific view you can do the same:

[scrollView setContentOffset:CGPointMake(0, targetView.frame.origin.y) animated:YES];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top