我正在尝试向具有 xib 的 UIViewController 添加自定义过渡。我尝试了几种方法,但它们都有相同的问题,视图显示的屏幕尺寸错误。
我当前的示例基于以下教程:使用 Swift 在 iOS 中自定义 UIViewController 转换 http://zappdesigntemplates.com/custom-uiviewcontroller-transition-ios-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%:
最后,我有另一个没有 xib 的 UIViewController,并且约束是通过编程设置的。该视图加载了相同的转换并且加载完美:
我需要更改什么才能使其与 XIB 一起使用?
我花了很长时间寻找这个问题的答案,然后从相关问题之一 https://stackoverflow.com/questions/34104481/custom-viewcontroller-transition-doesnt-resize-properly?rq=1在侧边栏中。
我需要做的就是将以下内容添加到我的动画师中:
toViewController.view.frame = fromViewController.view.frame
我希望有一天这可以帮助某人。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)