Using UIScrollView

This could be a simple problem. I have a UIScrollView with 3 views. I need to display 3 dots, for example Indicator (to indicate that the user has more pages). How to do it?

+5
source share
3 answers

use UIPageControl:

pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(...)]; // set in header
[pageControl setNumberOfPages:3];
[pageControl setCurrentPage:0];
[pageControl setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:pageControl];

This is a user interface component that shows dots ... the number of pages is the number of dots. The current page is the one currently highlighted.

Then you need to use the scroll delegate method to determine which page scrolls:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  int newOffset = scrollView.contentOffset.x;
  int newPage = (int)(newOffset/(scrollView.frame.size.width));
  [pageControl setCurrentPage:newPage];
}
+8
source

contentView, UIScrollView UIPageControl, numberOfPages of pageControl pageControl (currentPage).

Cheers,

0

You can use UIPageControl with 3 points on it. You will need screen space (provided that at the bottom of the screen) to put the page control so that your scrolling cannot be complete.

-1
source

All Articles