---
title: "Infinite Page Control"
description: "I just love UIPageControl, don’t you? It’s simple and intuitive, it does not get any more \"native\" than this since apple used it in SpringBoard for ages. UIPageControl is the perfect choice when you have a fullscreen UIScrollView (UICollectionView) with pagingEnabled and you want to encourage your users to “swipe to see more”."
url: https://manytomany.co/blog/infinite-page-control/
published: 2014-06-03
---

# Infinite Page Control

3 June 2014 · Daria Kopaliani

This is an archived article from the website of Factorial Complexity Ltd., an older incarnation of many-to-many. Information may be outdated or inaccurate.

I just love `UIPageControl`, don’t you? It’s simple and intuitive, it does not get any more “native” than this since apple used it in SpringBoard for ages. UIPageControl is the perfect choice when you have a fullscreen `UIScrollView` (`UICollectionView`) with `pagingEnabled` and you want to encourage your users to “swipe to see more”.

[DAPageControlView](https://github.com/daria-kopaliani/DAPageControlView) gives your users the exact same experience they get from `UIPageControl` and something more. While `UIPageControl` is a winner for static data, `DAPageControlView` might be a better choice for the case when you fetch your data from a server in chunks and/or do not know the total number of items.

Check out this video with a `UICollectionView` of `PictureViews`: at first it displays just 5 of them and as soon as the user reaches the 4th one, it requests the next chunk of pictures and displays them shortly after that.

Note, that after fetching the second “portion” of pictures, if we used `UIPageControl`, the dots would not fit the screen width, but `DAPageControlView` is scrollable and applies “perspective” effect to dots on the right and/or on the left if neccessary. If all dots can fit the screen `DAPageControlView` behaves exactly like `UIPageControl`.
Also there is an option to make the rightmost dot “blink” to let the user know that more items are loading.

If this might be useful for you, here is how it’s done:
`DAPageControlView` is just a `UICollectionView` that depending on the `contentOffset` of a `UIScrollView` it is binded with, automatically updates its `currentPage` and, if neccessary, resizes its rightmost or leftmost page indicator views (dots) if there are more pages to the right or to the left accordingly.

So here is a quick tutorial:
First you create your `DAPageControlView` just like you would create a `UIPageView`

```objc
self.pageControlView = [[DAPageControlView alloc] initWithFrame:CGRectMake(0., 0., 320., 15.)];
self.pageControlView.numberOfPages = self.pagesCount;
self.pageControlView.currentPage = 0;
[self.view addSubview self.pageControlView];
```

And of course you need a `UIScrollView` to bind it with. I have a `UICollectionView` as I want to reuse its subviews:

```objc
self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.pagingEnabled = YES;
self.collectionView.dataSource = self;
```

Now we need to let our `pageControlView` know about the `contentOffset` of the `collectionView`. The easiest way is to do this in `scrollViewDidScroll:` (`UIScrollViewDelegate` method)

```objc
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self.pageControlView updateForScrollViewContentOffset:self.collectionView.contentOffset.x];
}
```

And that’s pretty much it. There is a `DAPageControlViewDelegate` if you want to be notified when a `currentPage`property is changed (page indicator views can be selectable). Also there is a `numberOfPagesAllowingPerspective` to configure precisely that.

`DAPageControlView` is available through [CocoaPods](http://cocoapods.org/). To install it, simply add the following line to your Podfile:

```ruby
pod "DAPageControlView"
```

We would love to hear back from you if you find this useful or have any suggestions or even complaints.

![Vitalii](https://manytomany.co/vitalii-yellow.png)

## Hi. I'm Vitalii.

I’m a software developer, technical manager and solo entrepreneur. I have been building software products all my life. I am offering **CTO as a Service** at many-to-many.

## Contact me

Let me know what are you looking for. I will reach out to you via the provided email with quote and follow up questions. Alternatively, [book a call](https://calendly.com/many-to-many/intro) or reach me directy by email [hello@manytomany.co](mailto:hello@manytomany.co).

Or using your preferred messaging app:

 [![WhatsApp QR Code](https://manytomany.co/qr/qr-whatsapp.png)](https://wa.me/qr/QH6GQNCO5CZEO1)[WhatsApp](https://wa.me/qr/QH6GQNCO5CZEO1)

 [![Telegram QR Code](https://manytomany.co/qr/qr-telegram.png)](https://t.me/wicharek)[Telegram](https://t.me/wicharek)
