gpt4 book ai didi

ios - ViewWillTransitionToSize 打破了 Swift 3?

转载 作者:搜寻专家 更新时间:2023-10-30 21:51:03 32 4
gpt4 key购买 nike

当我旋转设备时,我正在使用 viewWillTransitionToSize 来调整我的滑出菜单,但它似乎在 Swift 3 中被破坏了?谁能帮我解决这个问题?我的代码如下所示:

func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: nil, completion: {
_ in

let controller = self.revealViewController().rightViewController

var frame = controller?.view.frame
frame?.size.height = UIScreen.main.bounds.size.height - self.navigationController!.navigationBar.frame.size.height - self.toolBar.frame.size.height - (UIApplication.shared.isStatusBarHidden ? 0 : 20)
controller?.view.frame = frame!
})
}

旋转设备时好像没有调用?

最佳答案

找出问题所在,迁移到 swift 3 所做的更改不正确,函数应如下所示:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: nil, completion: {
_ in

let controller = self.revealViewController().rightViewController

var frame = controller?.view.frame
frame?.size.height = UIScreen.main.bounds.size.height - self.navigationController!.navigationBar.frame.size.height - self.toolBar.frame.size.height - (UIApplication.shared.isStatusBarHidden ? 0 : 20)
controller?.view.frame = frame!
})

}

关于ios - ViewWillTransitionToSize 打破了 Swift 3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39705989/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com