代码之家  ›  专栏  ›  技术社区  ›  DiscDev

旋转时删除UIPageViewController上的pageIndicator

  •  1
  • DiscDev  · 技术社区  · 11 年前

    在横向时,我希望UIPageViewController的内容是全屏的,并且我希望隐藏页面指示符。在纵向中,我想显示页面指示符。

    我知道实现数据源方法是页面指示器显示/不显示的原因(请参见 https://stackoverflow.com/a/20749979/1103584 ),但正如我之前所说,我希望能够根据应用程序的方向选择性地隐藏它们。

    我该怎么做?我以前在其他应用程序中见过(App Annie中的图表),所以我知道这是可能的。在我看来,迭代UIPageViewController的子视图以找到UIPageControl的实例的答案听起来像是一个非常棘手的解决方案……必须有一种更“官方”的方法来实现。

    提前感谢。

    2 回复  |  直到 7 年前
        1
  •  1
  •   Justin Moser 0x141E    10 年前

    目前,在调用setViewControllers:direction:animated:completion:方法后,无法更改UIPageViewController的页面指示符的默认行为。希望在未来的更新中添加类似于隐藏导航栏的方法。

        2
  •  1
  •   Justin Moser 0x141E    10 年前

    尝试将此添加到代码中。。。

    - (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
    {
        [super willAnimateRotationToInterfaceOrientation:orientation duration:duration];
    
        UIPageControl *pageControl = [UIPageControl appearance];
    
        if (UIInterfaceOrientationIsLandscape(orientation)) 
        {
            pageControl.alpha = 0;
        }
        else if (UIInterfaceOrientationIsPortrait(orientation)) 
        {
            pageControl.alpha = 1;
        }
    }