当我展示 SecondViewController 时,第一个 UIViewController 中的安全区域插入更改为横向安全区域插入,它仅支持横向。
带有描述的涉及 TabBar 和 TableView 的错误的 GIF
第一视图控制器:
class ViewController: UIViewController {
@IBAction func showSecondVC(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "SecondViewController")
self.present(controller, animated: true, completion: {
print("completed")
})
}
override func viewSafeAreaInsetsDidChange() {
print(view.safeAreaInsets)
super.viewSafeAreaInsetsDidChange()
print(view.safeAreaInsets)
}
}
第二个视图控制器:
class SecondViewController: UIViewController {
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return [.landscape]
}
@IBAction func dismissYourSelff(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
}
控制台输出:
UIEdgeInsets(top: 44.0, left: 0.0, bottom: 34.0, right: 0.0)
UIEdgeInsets(top: 44.0, left: 0.0, bottom: 34.0, right: 0.0)
UIEdgeInsets(top: 0.0, left: 44.0, bottom: 21.0, right: 44.0)
UIEdgeInsets(top: 0.0, left: 44.0, bottom: 21.0, right: 44.0)
completed