刷新 UIPageViewController - 重新排序页面并添加新页面

Refresh UIPageViewController - reorder pages and add new pages(刷新 UIPageViewController - 重新排序页面并添加新页面)
本文介绍了刷新 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 - 重新排序页面并添加新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)