我对UIContainerView
有点问题。我containerView
中的每个元素都在我的UIPageController
此图片将更加明确:
所以在这里,我的蓝色按钮将位于UIImageView
(机器人的viewController)之下,我需要它。我不明白为什么,如果有人有我的想法。
结果:
我如何创建我的PageVieWController:
fileprivate func createPageViewController() {
let pageController = self.storyboard!.instantiateViewController(withIdentifier: "PageController") as! UIPageViewController
pageController.dataSource = self
if contentImages.count > 0 {
let firstController = getItemController(0)!
let startingViewControllers = [firstController]
pageController.setViewControllers(startingViewControllers, direction: UIPageViewControllerNavigationDirection.forward, animated: false, completion: nil)
}
pageViewController = pageController
addChildViewController(pageViewController!)
self.view.addSubview(pageViewController!.view)
pageViewController!.didMove(toParentViewController: self)
}
以及我如何实例化我的pageItem:
fileprivate func getItemController(_ itemIndex: Int) -> ABTutorialPageItemViewController? {
if itemIndex < contentImages.count {
let pageItemController = self.storyboard!.instantiateViewController(withIdentifier: "ItemController") as! ABTutorialPageItemViewController
pageItemController.itemIndex = itemIndex
pageItemController.imageName = contentImages[itemIndex]
return pageItemController
}
return nil
}
如果你想操纵,直接显示在行动中你可以使用这个项目: https://github.com/YanisSOTO/Simple-UIPageViewController-Example
答案 0 :(得分:0)
通过替换解决:
self.view.addSubview(pageViewController!.view)
到:
self.containerView.addSubview(pageViewController!.view)