Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController last page bounce effect?

I am using a UIPageViewController to flip through multiple page of content, currently I don't do anything when the user flips to the last page of the UIPageViewController because there is no more page to switch to, how would I achieve a bounce effect like scrolling to the end of the UIScrollView, so that it gives user some feedback it is the end of the sequence?

like image 236
Twinkiestar Avatar asked May 25 '12 20:05

Twinkiestar


1 Answers

Try this!

  1. Add an empty page before your 'first' page (and optionally set it to be hidden)
  2. After you have made the setup for your UIPageViewController, manually go to the second page, your 'first' page.
  3. In the pageViewController:viewControllerBeforeViewController: delegate method, check if the view will be the empty page. If so,
    1. manually go to the second page again, maybe after some delay. Or
    2. In some sort of way, disable the UIPanGestureRecognizer in your UIPageViewController

This may not be the perfect solution, but hopefully acceptable. I'm also going to do something like this later, so I'll maybe explain more then and try it out myself. Good luck!


//Edit

Ah.. if you want to have the bounce effect last instead (I recommend you to do both)..

  1. Skip this.
  2. Add an extra (or two if you have an odd number of pages and double-sided view) empty page(s) after all your other pages (and optionally set it/them to be hidden)
  3. In the pageViewController:viewControllerAfterViewController: delegate method, check if the view will be the (last) empty page. If so,
    1. manually go to the previous page, maybe after some delay. Or
    2. In some sort of way, disable the UIPanGestureRecognizer in your UIPageViewController

In (3), if you haven't disable the UITapGestureRecognizer, you will have to decide if it is the tap gesture, and then choose (3.1), else take the (3.2) route!

like image 53
Leonard Pauli Avatar answered Oct 04 '22 04:10

Leonard Pauli