Swift - 滚动视图和安全区域的布局问题
我对可滚动布局有疑问 我有两个 UiViewController :
一个在顶部,带有绿色背景(TopVC),另一个是红色(初始 VC),它们完全可滚动
当我启动应用程序时,我遇到了这个布局问题:我看到另一个 VC 的底部(绿色的)。
当我开始滚动时,这个布局问题消失了,我可以上下滚动而不会出现任何布局问题。(正如您所看到的,SafeAreaView 按预期覆盖了整个屏幕)
有人吗知道如何解决这个问题以便从正确的布局开始吗?
感谢
您提供信息,我已经测试过的项目:(github项目链接)
修复:
if let top
= UIApplication.shared.windows.first?.safeAreaInsets.top
{
scrollView.contentInset.top = -top
}
I have a problem with a scrollable layout
I have two UiViewController :
One on the top with a green background (TopVC) and the other is red (the initial VC) which are perfectly scrollable
When I start the app, I have this layout problem : I see the bottom of the other VC(the green one).
When I start to scroll, this layout problem dissapear and I can scroll up and down without any layout problem.( as you can see the SafeAreaView covers the entire screen as expected )
Does someone know how I can fix that in order to start with a correct layout ?
Thanks
For info, the project that I have tested :(link of the github project)
Fixed with :
if let top
= UIApplication.shared.windows.first?.safeAreaInsets.top
{
scrollView.contentInset.top = -top
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论