刷新 UIPageViewController - 重新排序页面并添加新页面 [英] Refresh UIPageViewController - reorder pages and add new pages

查看:23
本文介绍了刷新 UIPageViewController - 重新排序页面并添加新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIPageViewController,我正在为使用 UIPageControllerDelegateUIPageControllerDataSource 的实现提供页面数据.

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.

我想我在 UITableView 上寻找类似于 reloadData: 的东西.

I guess I'm looking for something similar to reloadData: on UITableView.

推荐答案

需要调用setViewControllers:direction:animated:completion:.

此外,在 iOS 6 中,请注意您是否使用 UIPageViewControllerTransitionStyleScroll 样式,因为如果 animated: 为 YES,则会出现主要的缓存错误(请参阅我的讨论:UIPageViewController 使用滚动过渡样式导航到错误页面).

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屋!

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