我有一个
例如:
当我首次初始化
然而,当我的
rootViewController
,其中包含一个子视图控制器(fullScreenViewController
),其视图不时地显示在rootViewController
的视图之上(但作为子视图),占据整个屏幕。例如:
rootViewController.addChildViewController(fullScreenViewController)
rootViewController.view.addSubview(fullScreenViewController.view)
此"全屏呈现"是通过约束更新实现的,而不是使用present()
(这样做有很好的理由)。当我首次初始化
fullScreenViewController
并将其添加为rootViewController
的子视图控制器,然后更新约束以使其显示在屏幕上时,safeAreaInsets
都被正确设置。然而,当我的
rootViewController
稍后实际上执行present()
一个模态VC,并且该VC被dismiss()
时,在fullScreenViewController
上的safeAreaInsets
不再正确,fullScreenViewController
中的内容会滑动到状态栏之上。如何强制重新计算fullScreenViewController
上的safeAreaInsets
,使其正确匹配rootViewController
,就像在设置后一样?根据文档,rootViewController
应该正确设置其所有childViewController
的安全区域,但实际情况并非如此。