The gap that appears on swiping UIPageViewController — Swift

廉价感情. 提交于 2019-12-25 09:28:57

问题


I have created a container for "modul screens" with UIPageViewController. The main problem is a wrong size if set previous screen.

On screenshot you can see that are showed 2 screens instead 1.

For setting a new screen I use

func launchViewControllerC(vc: USBaseVaultStepViewcontroller,
                           step: UIPageViewControllerNavigationDirection,
                           animated: Bool = true) {
    vc.delegate = self

    self.pageController.setViewControllers([vc],
                                           direction: step,
                                           animated: true,
                                           completion: nil)

}

and for the previous screen I use:

func launchPreviousScreen() {
    guard let previousStep = self.currentSetupStep.previousStep() else {
        return
    }

    guard let previousController = self.setupStepViewControllerForStep(previousStep) else {
        return
    }

    self.currentSetupStep = previousStep
    previousController.delegate = self

    self.pageController.setViewControllers([previousController],
                                           direction: UIPageViewControllerNavigationDirection.Reverse,
                                           animated: true,
                                           completion: nil)
}

TIP: It happens when setViewControllers has animated true. Also I have found out that completion block doesn't work properly.


回答1:


On a storyboard where is located my container with PageViewController I have disabled option Autoresize Subview. And the "gap" during animation disappeared.

But the description above isn't solution just a clue. The main problem was subHeader that showed on the screen. I was changing height constraint in runtime that is why UIPageViewController didn't know correct size of the screens. I had to separate my screens and I've made Inner screen. I'm using UIPageViewController in UIPageViewController. And for know animation works perfect.



来源:https://stackoverflow.com/questions/44973910/the-gap-that-appears-on-swiping-uipageviewcontroller-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!