我的swift 3代码中有这个方法:
func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
}
我尝试了以下内容:
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
}
但是我收到了这个错误:
Method does not override any method from its superclass
为什么不调用viewWillTransitionToSize?
答案 0 :(得分:2)
尝试
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator){
super.viewWillTransition(to: size, with: coordinator)
}
答案 1 :(得分:1)
关于从swift2.x迁移到Swift3'viewWillTransition'方法的迁移过程已经改变:
<强> Swift2.x 强>
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
<强> Swift3 强>
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
使用 将密钥 withTransitionCoordinator 更改为