在Xcode预览和真实设备上的布局不同

huangapple go评论79阅读模式
英文:

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:

Screenshot

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.

huangapple
  • 本文由 发表于 2023年7月27日 14:37:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76777073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定