问题
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