【发布时间】:2014-05-18 08:40:34
【问题描述】:
在我的应用程序中,主视图控制器中有一个导航栏和两个工具栏。然后,我在 UI 元素后面的主 VC 中有一个填充屏幕的容器视图。我在容器中嵌入了UIPageViewController。然后我设置了一个UICollectionViewController 场景,在页面之间滑动时可以重复使用该场景。这是在代码中完成的 - 见下文。基本上,它会在屏幕上显示UICollectionViewController。
它运行良好,但当它出现在屏幕上时,它会覆盖主 VC 的 UI。我可以更改高度以显示 UI,但我确实希望它占据整个屏幕。我只是希望它位于工具栏后面。这样,当用户滚动 Collection VC 时,内容将呈现在那些半透明的工具栏下方。
我明白它为什么会这样,但我不知道如何解决它。我最初认为,因为它都嵌入在一个容器中,所以它会尊重该容器的 z 顺序,这在故事板中看起来很好,但我想如果我只是在代码中将 VC 扔到屏幕上,我应该期待这种行为。我只是不确定如何获得所需的行为。感谢您的帮助!
//the following code is in the main view controller
//set first page view controller
ContentCollectionViewController *startingViewController = [self viewControllerAtIndex:0]; //calls method below
[self.pageViewController setViewControllers:@[startingViewController]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
//move page view controller down to reveal the underlying UI and show my issue
self.pageViewController.view.frame = CGRectMake(0, 80, self.view.frame.size.width, self.view.frame.size.height);
//display created page VC
[self addChildViewController:self.pageViewController];
[self.pageViewController didMoveToParentViewController:self];
[self.view addSubview:self.pageViewController.view];
//in the viewControllerAtIndex method:
ContentCollectionViewController *contentCollectionViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ContentCollectionViewController"];
//set properties here...
return contentCollectionViewController;
【问题讨论】:
标签: ios objective-c uicollectionview fullscreen uicollectionviewlayout