ios – ViewWillTransitionToSize在Swift 3中爆发了吗?

当我旋转设备时,我正在使用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,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 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...