【问题标题】:UIPageViewController programmatically turning pages does not update Page IndicatorUIPageViewController 以编程方式翻页不会更新页面指示器
【发布时间】:2013-02-01 02:08:28
【问题描述】:

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

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

如果实现了“支持页面指示器”中的两个方法,并且页面视图控制器的过渡样式为 UIPageViewControllerTransitionStyleScroll,则页面指示器是可见的。这两个方法都是在调用 setViewControllers:direction:animated:completion: 方法之后调用的。 手势驱动导航后,这些方法不会被调用。索引会自动更新,视图控制器的数量预计保持不变。

(见上面的粗体字)

UIPageViewController documenatation

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

提前感谢您的帮助。

【问题讨论】:

    标签: objective-c ios6 uipageviewcontroller ios6.1


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      表示你只设置了一次页数首页,不调用@就不能向Page Control添加(或删除)页面987654322@再次。

      它基本上是DataSource 协议中定义的只写属性。

      【讨论】:

        猜你喜欢
        • 2014-04-28
        • 1970-01-01
        • 1970-01-01
        • 2011-11-04
        • 1970-01-01
        • 1970-01-01
        • 2015-07-22
        • 2023-04-11
        • 1970-01-01
        相关资源
        最近更新 更多