UIPageViewController last page bounce effect?

I use UIPageViewController to turn over multiple pages of content, I currently do nothing when the user flips to the last page of the UIPageViewController because there is no page to switch anymore, as if I achieve a bounce effect, for example, scrolling to the end of the UIScrollView , so that it gives the user some feedback, is this the end of the sequence?

+6
source share
1 answer

Try it!

  • Add a blank page before your "first" page (and you can hide it if you wish)
  • After you have made the settings for your UIPageViewController, go to the second page - your first page.
  • In the pageViewController: viewControllerBeforeViewController: delegate method, verify that the view is an empty page. If so,
    • go back to the second page again, perhaps after some delay. Or
    • Somehow disable UIPanGestureRecognizer in your UIPageViewController

This may not be the ideal solution, but hopefully acceptable. I'm also going to do something similar later, so maybe I will explain more and try it myself. Good luck


// Change

Ah .. if you want the last bounce effect (I recommend that you do both).

  • Skip this one.
  • Add extra (or two if you have an odd number of pages and two-way viewing) blank pages after all of your other pages (and, optionally, you should hide it / them)
  • In the pageViewController: viewControllerAfterViewController: delegate method, verify that the view is (the last) blank page. If so,
    • manually go to the previous page, perhaps after some delay. Or
    • Somehow disable UIPanGestureRecognizer in your UIPageViewController

In (3), if you have not disabled the UITapGestureRecognizer, you will have to decide if this is a click gesture, then select (3.1) and then take the route (3.2)!

+1
source

Source: https://habr.com/ru/post/916702/


All Articles