视图的大小(宽度/高度)已更改

时间:2019-10-24 20:26:22

标签: ios swift viewcontroller navigationcontroller

我对view's框架有疑问。在ViewController内部的第一个NavigationBar中,我以编程方式更改了VC的方向。当我按下SecondVC时,SecondVC的宽度/高度已更改,就像width为height和height为width一样。表现得好像没有时间重新加载。在旧版本的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()
}

感谢您的帮助

编辑:我修复了它。当高度>宽度时,我只是控制,如果是的话,我会切换高度/宽度。这是最好的解决方案,但我现在还不了解。

0 个答案:

没有答案