每次Xcode重新启动时错误放置视图 [英] Misplaced views each time Xcode restarts
问题描述
我第一次在我的应用程序中使用故事板
I'm using storyboards for the first time in my app
当我关闭Xcode时,我有关于错误放置的视图或与我的故事板有关的任何内容的0警告。当我重新启动Xcode并打开故事板时,我的15个场景中有3个放错了视图警告。
When I close Xcode, I have 0 warnings about misplaced views or anything pertaining to my storyboard. When I restart Xcode and open the storyboard, 3 out of my 15 scenes have misplaced view warnings.
没有触及任何东西(除了选择文件),我可以发出一个 git status
并查看.storyboard文件是否有更改。如果我 git diff
,我看到这包含在文件的多个区域中:
Without touching anything (other than selecting the file), I can issue a git status
and see that the .storyboard file has changes. If I git diff
, I see this included in multiple areas of the file:
<variation key="widthClass=compact" misplaced="YES">
<rect key="frame" x="8" y="56" width="130" height="34"/>
</variation>
如果元素已经< variation key =widthClass = Compact
节点,然后添加错位的
属性和 rect
节点。
If an element already had <variation key="widthClass=Compact"
node, then the misplaced
attribute and rect
node are added.
要使警告消失,我唯一需要做的就是点击每一个,确保选择更新框架,然后单击修复错位。这会修复所有内容,直到我重新启动Xcode。
The only thing I have to do to get the warnings to go away is click on each one, make sure "Update Frame" is selected, and click "Fix Misplacement". That fixes everything until I restart Xcode.
我的场景的基本结构是:
The basic structure of my scene is:
UIView
UICollectionView
UICollectionReusableView
UICollectionViewCell
UICollectionViewCell
UISegmentedControl
每次重新启动时如何防止这种情况发生?
How can I prevent this from happening each time I restart?
推荐答案
在我的案例中它适用于所有带有自定义字体和内在(未明确定义)尺寸的标签/按钮。看起来像Xcode错误。
In my case it happens for all labels / buttons with custom fonts and intrinsic (not explicitly defined) sizes. Looks like an Xcode bug.
这篇关于每次Xcode重新启动时错误放置视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!