首页 > 解决方案 > Helo 在 xcode 中的调试器上,使用 swift 和 swiftUI 5

问题描述

你好

所以在对调试器进行了一些研究之后,我仍然不知道它是如何工作的:

    2021-08-29 05:04:47.699766+0200 TestbaseThemed[7017:392999] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x6000032c2b70 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7f9861d13590]-(6)-[_UIModernBarButton:0x7f9861d10e60'Theme'd']   (active)>",
    "<NSLayoutConstraint:0x6000032c2bc0 'CB_Trailing_Trailing' _UIModernBarButton:0x7f9861d10e60'Theme'd'.trailing <= _UIButtonBarButton:0x7f9861d10770.trailing   (active)>",
    "<NSLayoutConstraint:0x6000032c39d0 'UINav_static_button_horiz_position' _UIModernBarButton:0x7f9861d13590.leading == UILayoutGuide:0x6000028e0b60'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x6000032c3a20 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x7f9861d10770]-(0)-[UILayoutGuide:0x6000028e0a80'UINavigationBarItemContentLayoutGuide']   (active)>",
    "<NSLayoutConstraint:0x6000032c8eb0 'UINavItemContentGuide-trailing' UILayoutGuide:0x6000028e0a80'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x7f9863811270.trailing   (active)>",
    "<NSLayoutConstraint:0x6000032c40a0 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x7f9863811270.width == 0   (active)>",
    "<NSLayoutConstraint:0x6000032c9270 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x6000028e0b60'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x7f9863811270 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000032c2b70 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7f9861d13590]-(6)-[_UIModernBarButton:0x7f9861d10e60'Theme'd']   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

我目前正在尝试调试,它有点搞砸了我的程序。在它没有引起任何问题之前,因为我在程序午餐之前没有加载东西,但是现在,它给我带来了麻烦,因为一旦错误出现,func停止运行并且它不会加载其余的内容它应该加载

我也想在做任何其他事情之前等待函数完成,但是我知道怎么做,所以我想我必须处理调试

提前感谢您的回答!

(所以,幸运的是我发现了错误,但我不知道为什么会这样:.navigationTitle("Theme'd") .navigationBarTitleDisplayMode(.large))我很幸运

标签: swiftxcodedebuggingswiftui

解决方案


通常,其中一项约束不够灵活,无法根据屏幕大小调整大小。

例如,如果您有一个应该是宽度为 200 并且左右边距为 0 的视图。除非设备宽度为 200,否则此处不能同时满足所有 3 个。

我提到的上述示例的解决方案将是以下之一 -

  1. 删除其中一个约束
  2. 将约束之一设为大于/小于
  3. 降低约束之一的优先级

结果将是视图将向左或向右移动并具有 200 宽度,或者它将具有边距 0 和灵活宽度。


推荐阅读