【发布时间】:2022-04-28 16:21:14
【问题描述】:
我正在使用 UIPageViewController 全屏显示图像,作为子视图/子视图添加到 UIPageController 的 UIViewController 使用 ImageView 显示图像。 问题是图像不是全屏显示,而是页面控件视图的不显示在底部,并且完全浪费了空间。请检查所附图片。
这里是代码
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 实现了 UIPageViewControllerDataSource 协议和 MainViewController 中的必要方法。
我相信必须有一种方法可以全屏显示内容。
*** 如果重要的话,MainViewController 也是故事板的一部分。
【问题讨论】:
-
你应该使用 UIPageControl 和 UIScrollView 代替,然后你有细粒度的控制。
-
向我们展示一些有关如何设置页面视图控制器的代码。
-
@JohnWoods 必须有一种方法,因为 UIPageViewController 应该替换 UIPageControl 和 ScrollView 加上我想要在 xib 编辑器中设计视图的灵活性,我不会在你提到的方法中得到。
-
@bilobatum 添加了代码,请检查。我可以从 UIPageViewController 中搜索 PageControl 并将其隐藏,但该空间仍然存在。
-
好的,上面的代码看起来不错。所以我们可以排除这个问题。让我们看看别处。您的 NewsItemViewController 是否包含任何布局代码?
标签: ios objective-c uipageviewcontroller