RazzleDazzle icon indicating copy to clipboard operation
RazzleDazzle copied to clipboard

Is it possible to have pagination?

Open tundsdev opened this issue 9 years ago • 8 comments

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

tundsdev avatar Dec 13 '15 20:12 tundsdev

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

maxmeyers avatar Dec 16 '15 00:12 maxmeyers

+1

martnst avatar Jan 25 '16 22:01 martnst

+1

vincent-peng avatar Mar 23 '16 03:03 vincent-peng

+1

dareApple avatar May 09 '16 08:05 dareApple

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. :)

andreyrd avatar Jun 07 '16 17:06 andreyrd

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.

martnst avatar Jun 09 '16 12:06 martnst

Adding override func scrollViewDidScroll(scrollView: UIScrollView) { }

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

nharbo avatar Apr 20 '17 10:04 nharbo

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)
	}
}

vincent-peng avatar Apr 23 '17 11:04 vincent-peng