我有一个scrollView包含2个子viewController。您会看到VC2布局不正确。
我发现 View 在屏幕上尚不可见。safeAreaInsets
始终为0。
滚动结束时,我可以调用vc2.view.setNeedsLayout()
来解决此问题。
但是,直到滚动结束,布局才正确。
document说
那么我该如何解决这种情况。
自动布局
最佳答案
而不是引用当前 View 的safeAreaInsets,将其设置为UIApplication:
(UIApplication.shared.delegate?.window??.safeAreaInsets.bottom)