简体   繁体   English

UIPageViewController最后一页弹跳效果?

[英]UIPageViewController last page bounce effect?

我正在使用UIPageViewController来翻阅多个内容页面,当用户UIPageViewController的最后一页时我没有做任何事情,因为没有更多的页面要切换到,我怎样才能实现像滚动一样的反弹效果到UIScrollView的末尾,以便它给用户一些反馈它是序列的结束?

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. 完成UIPageViewController的设置后,手动转到第二页,即“第一页”。
  3. In the pageViewController:viewControllerBeforeViewController: delegate method, check if the view will be the empty page. 在pageViewController:viewControllerBeforeViewController:delegate方法中,检查视图是否为空页面。 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 在某种程度上,禁用UIPageViewController中的UIPanGestureRecognizer

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. 在pageViewController:viewControllerAfterViewController:delegate方法中,检查视图是否为(最后)空页面。 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 在某种程度上,禁用UIPageViewController中的UIPanGestureRecognizer

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! 在(3)中,如果你没有禁用UITapGestureRecognizer,你将必须决定它是否是点击手势,然后选择(3.1),否则采取(3.2)路线!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM