本文介绍了访问iOS6 UIPageViewController创建的UIPageControl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UIPageViewController ,导航设置为Horizo​​ntal,Transition Style设置为Scroll(在InterfaceBuilder中),没有脊椎。这给了我一个可爱的UIPageControl集成。现在我希望能够切换它是否正在显示(因为它下面有艺术品)。

I'm using a UIPageViewController with Navigation set to Horizontal, Transition Style set to Scroll (in InterfaceBuilder), and no spine. Which gives me a lovely UIPageControl integrated. Now I want to be able to toggle whether it's displaying (because there's artwork underneath it).

我试过设置 presentationCountForPageViewController presentationIndexForPageViewController UIPageControl 应该被隐藏时返回0,但这些方法不是在我想要的时候调用。

I've tried setting presentationCountForPageViewController and presentationIndexForPageViewController to return 0 when the UIPageControl is supposed to be hidden, but those methods aren't being called when I want.

暂停堆栈跟踪,我看到它们被 [UIPageViewController _updatePageControlViaDataSourceIfNecessary] 调用...我认为如果我尝试使用该方法,我的应用程序将被拒绝。

Pausing for stacktrace, I see them being called by [UIPageViewController _updatePageControlViaDataSourceIfNecessary]...I assume my app would be rejected if I tried to use that method.

我应该通过子视图搜索它,还是自己滚动以便我可以控制它,或者有没有更好的方法来切换其可见性?

Should I hunt through subviews for it, or roll my own so I have control over it, or is there some better way to toggle its visibility?

谢谢!

推荐答案

我会说,通过子视图进行搜索。此代码在子视图层次结构中成功找到UIPageControl:

I would say, hunt through the subviews. This code successfully finds the UIPageControl in the subviews hierarchy:

NSArray *subviews = pageController.view.subviews;
UIPageControl *thisControl = nil;
for (int i=0; i<[subviews count]; i++) {
    if ([[subviews objectAtIndex:i] isKindOfClass:[UIPageControl class]]) {
        thisControl = (UIPageControl *)[subviews objectAtIndex:i];
    }
}

我用它来自定义颜色点,我想你可以用alpha值做同样的事情或者把它发送到后面或者什么。

I'm using this to customize the color of the dots, I imagine you could do the same with the alpha value or send it to the back or something.

Apple没有通过UIPageViewController类提供到UIPageControl的直接接口,但是没有非法的方法调用才能达到它...我不明白为什么这会导致应用被拒绝。

Apple provides no direct interface to the UIPageControl through the UIPageViewController class, but there are no illegal method calls required in order to get to it... I don't see why this would result in an app rejection.

这篇关于访问iOS6 UIPageViewController创建的UIPageControl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 04:09