【问题标题】:Adding a custom transition causes xib to load for the wrong screen size添加自定义过渡会导致 xib 加载错误的屏幕尺寸
【发布时间】:2017-11-16 10:07:49
【问题描述】:

我正在尝试向具有 xib 的 UIViewController 添加自定义转换。我尝试了几种方法,但它们都有相同的问题,视图显示错误的屏幕尺寸。

我当前的示例基于以下教程:Custom UIViewController transition in iOS with Swift

我没有对 TransitionDelegate 或 Animators 进行任何更改。

这是 xib 和模拟器中的视图:

白色 UIView 设置为居中,宽度为 80%,比例为 1:1。

我的 UIViewController 使用以下内容加载:

let thirdViewController = ThirdViewController()
    thirdViewController.transitioningDelegate = viewTransitionDelegate
    thirdViewController.modalPresentationStyle = .custom
    navigationController?.present(thirdViewController, animated: true, completion: nil)

如果我注释掉设置委托,视图将 100% 完美加载:

最后,我有另一个 UIViewController 没有 xib 并且约束是通过编程设置的。这个视图加载了相同的过渡并且完美加载:

我需要进行哪些更改才能使其与 XIB 一起使用?

【问题讨论】:

    标签: ios uiviewcontroller xib uiviewanimationtransition


    【解决方案1】:

    我花了很长时间寻找这个问题的答案,然后从边栏中的one of the related questions 找到它。

    我需要做的就是将以下内容添加到我的动画师中:

    toViewController.view.frame = fromViewController.view.frame
    

    我希望有一天这对某人有所帮助。

    【讨论】:

    • 太棒了!!!工作正常!我尝试使用每种类型的“布局子视图解决方案”,但显然在使用自定义转换时,xib 或故事板文件会被覆盖。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多