【发布时间】:2018-07-06 16:35:51
【问题描述】:
我有一个 rootViewController,它有一个子视图控制器 (fullScreenViewController),其视图不时显示在 上方 @987654327 的视图(但作为子视图) @,占据全屏。
即
rootViewController.addChildViewController( fullScreenViewController )
rootViewController.view.addSubview( fullScreenViewController.view )
这个“全屏演示”是通过约束更新完成的,不是使用present()(这是有充分理由的)。
当我第一次初始化fullScreenViewController 并将其添加为rootViewController 的子视图控制器,然后更新约束使其显示在屏幕上时,safeAreaInsets 都已正确设置。
但是,稍后,当我的rootViewController 实际使用present() 模态VC,并且该VC 是dismiss()ed 时,fullScreenViewController 上的safeAreaInsets 不再正确,并且中的内容fullScreenViewController 在状态栏顶部向上滑动。
如何强制正确重新计算fullScreenViewController 上的safeAreaInsets,以便它们与设置后的rootViewController 匹配?
根据文档,rootViewController 应该在其所有childViewControllers 上正确设置 safeAreaInsets,但似乎并非如此。
【问题讨论】:
-
我有完全相同的问题,在容器视图控制器上方显示模态框会弄乱孩子的安全区域插图。您在哪里可以找到此问题的原因或解决方法?
标签: ios autolayout safearealayoutguide