1

I have a UIScrollView, on this view, I add more UIView, like this

enter image description here

When I scroll up or down, I want the UIView full display, the effect like UIPageControl, but I just want change one cell or more, not a page.

How could I do it? Thanks.

Edit

The effect like this here

But I want use to control all the UIView, and scroll up and down just one or more UIView.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
lighter
  • 2,808
  • 3
  • 40
  • 59
  • 1
    Whats wrong with `UITableview` ? – Toseef Khilji Jan 16 '14 at 10:32
  • In my `UIView` have another thing to do, so I use `UIScrollView` – lighter Jan 16 '14 at 10:34
  • what you done with UIview you can also do with it. – Toseef Khilji Jan 16 '14 at 10:37
  • If I use `UITableView`. How to achieve this effect? Thanks. – lighter Jan 16 '14 at 10:47
  • There are many question realted with tableview make little effort for search. http://stackoverflow.com/questions/15081648/how-to-implement-loading-more-for-table-view-when-scroll-to-bottomi-e-pull-up , http://stackoverflow.com/questions/15354133/load-data-on-uitableview-scroll, http://stackoverflow.com/questions/18000255/how-to-add-load-more-page-when-scrolling-to-bottom-of-table – Toseef Khilji Jan 16 '14 at 10:51
  • how about implementing a snap functionality for your tableview?. This is much more useful then the way you are doing now. – Totumus Maximus Jan 16 '14 at 16:01

1 Answers1

0

I found the answer.

The answer reference [this]

Use UIScrollView can achieve this effect.

Edit

In order scroll accuracy, I use fmodf. This can reference [this].

This is my code.

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    float toMove = fmodf(scrollView.contentOffset.y, _cellHeight);

    if(toMove < _cellHeight / 2)
        [scrollView setContentOffset:CGPointMake(0, scrollView.contentOffset.y - toMove) animated:YES];
    else
        [scrollView setContentOffset:CGPointMake(0, scrollView.contentOffset.y + (_cellHeight - toMove)) animated:YES];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [self scrollViewDidEndDecelerating:scrollView];
}
Community
  • 1
  • 1
lighter
  • 2,808
  • 3
  • 40
  • 59