Ios 视图';s尺寸(宽度/高度)已更改

Ios 视图';s尺寸(宽度/高度)已更改,ios,swift,viewcontroller,navigationcontroller,Ios,Swift,Viewcontroller,Navigationcontroller,我对视图的框架有问题。在导航栏内的第一个视图控制器中,我以编程方式更改VC的方向。当我按下SecondVC时,SecondVC的宽度/高度发生了变化,比如宽度是高度,高度是宽度。它的行为就像没有时间重新加载一样。在旧版本的iOS中,它没有任何问题,但问题出现在iOS 13中 我在FirstVC中的代码 override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) UIDe

我对
视图的
框架有问题。在
导航栏
内的第一个
视图控制器
中,我以编程方式更改VC的方向。当我按下SecondVC时,
SecondVC
的宽度/高度发生了变化,比如宽度是高度,高度是宽度。它的行为就像没有时间重新加载一样。在旧版本的iOS中,它没有任何问题,但问题出现在iOS 13中

我在FirstVC中的代码

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    UIDevice.current.beginGeneratingDeviceOrientationNotifications()
    UIApplication.shared.isIdleTimerDisabled = false
    UIApplication.shared.keyWindow?.windowLevel = .normal
    let value = UIInterfaceOrientation.portrait.rawValue
    UIDevice.current.setValue(value, forKey: "orientation")
    UIDevice.current.endGeneratingDeviceOrientationNotifications()
}
谢谢你的帮助

编辑:我修好了。我只是控制,当高度>宽度时,如果是这样,我就切换高度/宽度。这不是最好的解决办法,但我现在还不知道更好的办法