Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to have pagination? #14

Open
tundsdev opened this issue Dec 13, 2015 · 8 comments
Open

Is it possible to have pagination? #14

tundsdev opened this issue Dec 13, 2015 · 8 comments

Comments

@tundsdev
Copy link

Hi i was wondering if you've developed pagination within the framework so that there's circles at the bottom of the screen to show the user the current view which they are on? Like the image attached.

screen shot 2015-12-13 at 20 15 39

@maxmeyers
Copy link

This is a great idea! We'd welcome a pull request for it, but not something we're planning to work on soon.

@martnst
Copy link

martnst commented Jan 25, 2016

+1

2 similar comments
@vincent-peng
Copy link

+1

@dareApple
Copy link

+1

@andreyrd
Copy link

andreyrd commented Jun 7, 2016

You can add a UIPageControl manually and wire it up manually like so:

class PagedViewController: AnimatedPagingScrollViewController {

    // Set this up using your preferred method, make sure it's on all pages
    private let pageControl: UIPageControl

    override func scrollViewDidScroll(scrollView: UIScrollView) {
        super.scrollViewDidScroll(scrollView)
        pageControl.currentPage = Int(pageOffset + 0.5)
    }
}

I add 0.5 to the offset so that the page control changes right in between pages.

Edit: Added super.scrollViewDidScroll(scrollView) so that we don't take away whatever RazzleDazzle does on scroll. :)

@martnst
Copy link

martnst commented Jun 9, 2016

as @andreyrd showed it is actually super easy to add a UIPageControl. I did so myself (just never managed to post it here). Therefor my suggestion is to not add a build in UIPageControl, but (since it's common) to provide a tutorial how to add a fully customizable UIPageControl yourself. I guess a wiki page would be the best place to put it. I'll be happy to share my implementation if a tutorial / how to is the way to move with this issue.

@nharbo
Copy link

nharbo commented Apr 20, 2017

Adding
override func scrollViewDidScroll(scrollView: UIScrollView) {
}

ruins the animations.. At least it does for me.. So any other suggestions? :)

@vincent-peng
Copy link

Here what I did previously, hope that would help,

@IBOutlet weak var introPageControl: UIPageControl!

// Page Change Listener
internal override func scrollViewDidScroll(_ scrollView: UIScrollView) {
	super.scrollViewDidScroll(scrollView)

	let screenSize: CGRect = UIScreen.main.bounds
	if scrollView.contentOffset.x.truncatingRemainder(dividingBy: screenSize.width) == 0 {
		let index = scrollView.contentOffset.x / screenSize.width
		// Set the new page index to the page control
		introPageControl.currentPage = Int(index)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants