如何删除UIPageViewController的底部间隙 [英] How to remove the bottom gap of UIPageViewController

查看:190
本文介绍了如何删除UIPageViewController的底部间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIPageViewController全屏显示图像,UIViewController被添加到UIPageController作为子视图/子图像使用ImageView显示图像。
问题是图像没有全屏显示,而是页面控制视图的底部显示在底部,并且该空间完全被浪费。请查看附带的图片。

I am using UIPageViewController to show images full screen, the UIViewController which is added to UIPageController as a sub view / child has the images being showed using ImageView. Problem is the images arent comming fullscreen, instead the pagecontrol view's donts are appearing at the bottom and that space is completely wasted. Please check the image attached.

这是代码

self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

self.pageController.dataSource = self;
[[self.pageController view] setFrame:[[self view] bounds]];

NewsItemViewController *initialViewController = [self viewControllerAtIndex:0];

NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];

[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];

这里NewsItemViewController是显示图像和一些文本的UIViewController,MainViewController在MainViewController中实现UIPageViewControllerDataSource协议和必要的方法。

Here NewsItemViewController is UIViewController showing images and some text and The MainViewController implements UIPageViewControllerDataSource protocol and necessary methods in MainViewController.

我认为必须有一种方法可以全屏显示。

I believe there has to be a way to do show the things in full screen.

***如果重要的话,MainViewController也是故事板的一部分。

*** Also the MainViewController is a part of a storyboard if that matters.

推荐答案

最后我自己得到了解决方案我只是隐藏了页面控件UIViewPageController然后扩展UIPageViewController的大小以掩盖由于缺少页面控制而留下的空白。

Finally got the solution myself I just hide the page control from UIViewPageController and then extended the size of the UIPageViewController to cover up the gap left due to absense of page control.

 NSArray *subviews = self.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];
    }
}

thisControl.hidden = true;
self.pageController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height+40);

这篇关于如何删除UIPageViewController的底部间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆