英文:
Different Layout in Xcode Preview and Real Device
问题
我是Swift UI的初学者,最近开始学习并且在一个个人的初学者项目上进行工作。问题是,在Xcode预览中,内容似乎是居中对齐的,这正是我想要的。但是当我在我的iPhone上或模拟器上运行应用程序时,内容的位置发生了变化。我不确定为什么会发生这种情况。
如下面的截图所示:
我认为在我实现背景图像之前,它运行得很好。但是我不确定它是什么时候开始这样做的。
英文:
I am a beginner in Swift UI, I recently started learning it and was working on a personal beginner project. So the issue is, the contents seem to be center aligned in the xcode preview, and that is how i want it. But when I run the application in my iphone or on a simulator, the contents mode their places. I am not sure why is this happening.
As you can see in the screenshot below:
I think it worked fine before I implemented the background image. But I am not really sure when it started to do like that.
答案1
得分: 0
请验证您是否正确设置了垂直和水平约束。因为此问题的原因是子视图没有正确对齐。
如果可能,请给我看一下代码。
英文:
Do verify you've set vertically and horizontally constraints right. Because the reason behind this issue is that subviews aren't aligned properly.
Show me the code if possible.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论