Вопрос

When in landscape, I would like the content of the UIPageViewController to be full screen, and I want to hide the page indicators. In portrait, I want to show the page indicators.

I know that implementing the data source methods are what make the page indicators show/not show (see https://stackoverflow.com/a/20749979/1103584), but as I stated earlier, I want to be able to selectively hide them depending on the orientation of my app.

How can I do this? I've seen it in other apps before (the graphs in App Annie) so I know it's possible. An answer where you iterate through subviews of the UIPageViewController to find an instance of UIPageControl sounds like a very hacky solution to me...there must be a more "official" way to do it.

Thanks in advance.

Это было полезно?

Решение

Currently, there is no way to change the default behavior of UIPageViewController's page indicator after the setViewControllers:direction:animated:completion: method is called. Hopefully, a similar method to hiding a navigation bar will be added in a future update.

Другие советы

Try adding this to your code...

- (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;
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top