UIPageViewController:返回当前可见视图 [英] UIPageViewController: return the current visible view

查看:274
本文介绍了UIPageViewController:返回当前可见视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么知道 UIPageViewController 里面显示的当前页面/视图是什么?



我已经覆盖了我的子视图的 viewDidAppear 方法,以便他们在 viewDidAppear 方法中向父视图发送一个id。 / p>

然而,问题在于:我无法可靠地将该ID用作显示页面的id。因为如果用户转动页面但中途决定停止转动并将页面放回,则已经调用 viewDidAppear 。 (视图在卷曲页面后面可见)。



如果当前视图消失,我可能只会切换到新的ID。但我想知道是否有更简单的方法来返回当前可见的视图?

解决方案

您应该手动跟踪当前页面。委托方法 pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:将告诉您何时更新该变量。方法 transitionCompleted:的最后一个参数可以告诉您用户是否完成了翻页过渡。


How do you know what is the current page/view displayed inside an UIPageViewController?

I have overridden the viewDidAppear method of my child views, so that they send an id to the parent view in their viewDidAppear method.

However, the problem is this: i cannot reliably use that id as id for the displayed page. because if the user turns the page but halfway through decides to stop the turning and put the page back, viewDidAppear will already have been called. (the view is visible behind the curled page).

Maybe i should only switch to a new id if the current view disappears. But I wonder if there is not a more simple way to return the view that is currently visible?

解决方案

You should manually keep track of the current page. The delegate method pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted: will tell you when to update that variable. The last argument of the method transitionCompleted: can tell you whether a user completed a page turn transition or not.

这篇关于UIPageViewController:返回当前可见视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆