刷新UIPageViewController - 重新排序页面并添加新页面 [英] Refresh UIPageViewController - reorder pages and add new pages
问题描述
我有一个 UIPageViewController
它提供页面数据使用 UIPageControllerDelegate
和 UIPageControllerDataSource
。
I have a UIPageViewController
which I am providing page data for using an implementation of UIPageControllerDelegate
and UIPageControllerDataSource
.
这一切都很好,但我想能够添加项目到页面数据和重新排序页面数据。
It's all working fine, but I want to be able to add items to the page data and reorder the page data.
如果用户已经到达最后一个页面,然后添加一个项目,他们无法进入下一页,因为 viewControllerAfterViewController:
已被调用。如果他们向后滚动一个,然后向前转两个,他们可以得到新的页面,所以数据设置正确。我如何告诉 UIPageViewController
刷新它的下一个存储?
If a user has already got to the last of the pages, and then I add an item, they can't get to the next page because viewControllerAfterViewController:
has already been called. If they scroll back one and then forward two they can get to the new page fine, so the data is setup correctly. How can I tell the UIPageViewController
to refresh its store of what comes next?
同样,我想重新排序是支持页面视图的集合。但是,如果我这样做,我会得到同样的问题 - 页面视图将认为下一页仍然是上一次加载当前页面。
Similarly I would like to reorder the collection that is backing the page view. But if I do this I'll get the same problem - the page view will think the next page is still what it was last time the current page was loaded.
我猜猜我在寻找类似 reloadData:在
UITableView
。
I guess I'm looking for something similar to reloadData:
on UITableView
.
推荐答案
您需要调用 setViewControllers:direction:animated:completion:
。
此外,在iOS 6中,请注意,如果你使用UIPageViewControllerTransitionStyleScroll样式,因为如果 animated:
是一个主要的缓存错误此处讨论: UIPageViewController使用Scroll导航到错误的页面转换样式)。
Also, in iOS 6, watch out if you're using UIPageViewControllerTransitionStyleScroll style, as there is a major caching bug if animated:
is YES (see my discussion here: UIPageViewController navigates to wrong page with Scroll transition style).
这篇关于刷新UIPageViewController - 重新排序页面并添加新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!