滑动 UIPageViewController 出现的间隙 -- Swift [英] The gap that appears on swiping UIPageViewController -- Swift

查看:34
本文介绍了滑动 UIPageViewController 出现的间隙 -- Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 UIPageViewController 创建了一个用于模块化屏幕"的容器.主要问题是如果设置前一个屏幕的大小错误.

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

在屏幕截图上,您可以看到显示了 2 个屏幕而不是 1 个.

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)
}

提示:当 setViewControllerstrue 设置动画时会发生这种情况.我还发现 completion 块不能正常工作.

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

推荐答案

在我的带有 PageViewController 的容器所在的故事板上,我禁用了选项 Autoresize Subview.动画过程中的间隙"消失了.

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

但上面的描述并不是解决方案,只是一个线索.主要问题是显示在屏幕上的子标题.我在运行时更改了高度约束,这就是 UIPageViewController 不知道屏幕正确大小的原因.我不得不分开我的屏幕,我已经制作了内屏.我在 UIPageViewController 中使用 UIPageViewController.并且知道动画作品完美.

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.

这篇关于滑动 UIPageViewController 出现的间隙 -- Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆