每次 Xcode 重新启动时视图错位

Misplaced views each time Xcode restarts(每次 Xcode 重新启动时视图错位)
本文介绍了每次 Xcode 重新启动时视图错位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次在我的应用中使用故事板

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" 节点,则添加 misplaced 属性和 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 重新启动时视图错位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)