Refresh UIPageViewController - reorder pages and add new pages(刷新 UIPageViewController - 重新排序页面并添加新页面)
问题描述
我有一个 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.
我想我在 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 - 重新排序页面并添加新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:刷新 UIPageViewController - 重新排序页面并添加新页面
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
