objective-c - UIPageViewController 以编程方式翻页不更新页面指示器

标签 objective-c ios6 uipageviewcontroller ios6.1

当我使用类似于 this answer 的方法以编程方式在 UIPageViewController 中翻页时,页面指示器不会更新。滑动到下一页/上一页会按预期更新页面指示器。以编程方式翻页时,我需要做什么来更新页面指示器?即,如何在以编程方式更改页面后设置当前“索引”,以便页面指示器知道哪个页面指示器显示为事件状态?

我在文档中注意到,说明如下:

If both of the methods in “Supporting a Page Indicator” are implemented and the page view controller’s transition style is UIPageViewControllerTransitionStyleScroll, a page indicator is visible. Both of these methods are called after the setViewControllers:direction:animated:completion: method is called. After gesture-driven navigation, these methods are not called. The index is updated automatically and the number of view controllers is expected to remain constant.

(见上文粗体)

UIPageViewController documenatation

这是否意味着如果您不使用手势翻页,那么就没有办法更新 UIPageIndicators?

预先感谢您的帮助。

最佳答案

您可以使用正确的页面索引实现以下数据源协议(protocol)方法:

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
{
 NSInteger currentPageIndex=0;
 //find out actual page index of the current view controller
return currentPageIndex;
}

关于objective-c - UIPageViewController 以编程方式翻页不更新页面指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14905902/

相关文章:

ios - 在 iOS 中使用正向地理编码获取多个地址的纬度和经度时如何添加延迟?

ios - UIView 的不透明度和 alpha 是否相同

ios - 如何从 UIImageView 压缩图像?

ios7 - NavigationController 中的 UIPageViewController

ios - 核心数据 : How to correctly use migratePersistentStore to create a backup copy

ios - 链接器命令失败,退出代码为 1

iphone - iOS 中带分页的 UICollectionView 的页数

iOS 6 : UIDatePicker in the UITextField

ios - 未调用 UIPageViewController 的数据源方法

ios - 滚动应用 : UIPageViewController vs UIScrollView