xcode 报错,有老哥看看这是怎么回事吗?

2019-07-09 09:49:59 +08:00
 aria955

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x280764780 H:[_UIModernBarButton:0x143dae800]-(>=5)-| (active, names: '|':_UIButtonBarButton:0x143dae1b0 )>

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. 2019-07-09 09:42:56.139575+0800 imatrixh5app[1006:633541] [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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x280764960 h=-&- v=-&- _UIToolbarContentView:0x143d4f810.width == UIToolbar:0x143d4f3d0.width (active)>", "<NSLayoutConstraint:0x28075b200 H:|-(0)-[_UIButtonBarStackView:0x143d50bd0] (active, names: '|':_UIToolbarContentView:0x143d4f810 )>", "<NSLayoutConstraint:0x28075bf70 _UIButtonBarStackView:0x143d50bd0.trailing == _UIToolbarContentView:0x143d4f810.trailing (active)>", "<NSLayoutConstraint:0x280766990 H:|-(8)-[_UIModernBarButton:0x143daf8b0'Done'] (active, names: '|':_UIButtonBarButton:0x143daed20 )>", "<NSLayoutConstraint:0x280766350 H:[_UIModernBarButton:0x143daf8b0'Done']-(16)-| (active, names: '|':_UIButtonBarButton:0x143daed20 )>", "<NSLayoutConstraint:0x28077fc50 'UISV-canvas-connection' UILayoutGuide:0x281d4ea00'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x143e68f40.leading (active)>", "<NSLayoutConstraint:0x28077fc00 'UISV-canvas-connection' UILayoutGuide:0x281d4ea00'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x143daed20.trailing (active)>", "<NSLayoutConstraint:0x280767b60 'UISV-spacing' H:[_UIButtonBarButton:0x143e68f40]-(0)-[UIView:0x143dadfd0] (active)>", "<NSLayoutConstraint:0x2807661c0 'UISV-spacing' H:[UIView:0x143dadfd0]-(0)-[_UIButtonBarButton:0x143dae1b0] (active)>", "<NSLayoutConstraint:0x280767cf0 'UISV-spacing' H:[_UIButtonBarButton:0x143dae1b0]-(0)-[UIView:0x143daeb40] (active)>", "<NSLayoutConstraint:0x280767e80 'UISV-spacing' H:[UIView:0x143daeb40]-(0)-[_UIButtonBarButton:0x143daed20] (active)>",

"<NSLayoutConstraint:0x2807671b0 'UIView-Encapsulated-Layout-Width' UIToolbar:0x143d4f3d0.width == 0   (active)>",
"<NSLayoutConstraint:0x2807597c0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x281d4ea00'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UIButtonBarStackView:0x143d50bd0 )>",
"<NSLayoutConstraint:0x28075b480 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x281d4ea00'UIViewLayoutMarginsGuide']-(0)-|(LTR)   (active, names: '|':_UIButtonBarStackView:0x143d50bd0 )>"

)

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x280766350 H:[_UIModernBarButton:0x143daf8b0'Done']-(16)-| (active, names: '|':_UIButtonBarButton:0x143daed20 )>

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. 2019-07-09 09:43:00.332944+0800 imatrixh5app[1006:633541] didDisconnectPeripheral 2019-07-09 09:43:17.569429+0800 imatrixh5app[1006:633541] didConnectPeripheral 2019-07-09 09:43:19.459614+0800 imatrixh5app[1006:633541] didDisconnectPeripheral

4963 次点击
所在节点    iOS
7 条回复
paullee
2019-07-09 09:54:17 +08:00
这个是你加了 Alert Actionsheet 出来的吧,我查到的资料说是 iOS12.x 的 bug。。。
paullee
2019-07-09 09:55:26 +08:00
另外,我是业余选手,不具有参考性哈。
jameskuk
2019-07-09 09:57:29 +08:00
约束冲突了,自己查查自己的约束,口算一下
aria955
2019-07-09 10:18:55 +08:00
@paullee 我是用做的 hybirdAPP 用的 cordova 蓝牙插件 点击监测数据变化的时候就会报错
@jameskuk 我去百度一下 真的不懂啥意思 不是 ios 纯前端
arnoldxiao
2019-07-09 10:21:17 +08:00
约束冲突,仔细核查
vincentxue
2019-07-09 10:42:58 +08:00
这就是约束冲突了。

约束就是 Auto Layout 的约束,具体类是 NSLayoutConstraint。打开生成的 Xcode 工程,打个名叫 UIViewAlertForUnsatisfiableConstraints 的 symbolic 断点,怎么打可以谷歌一下。还有其他方法做调试,详见官方文档: https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/DebuggingTricksandTips.html

具体来说,你是下面两个约束冲突了:

"<NSLayoutConstraint:0x280766990 H:|-(8)-[_UIModernBarButton:0x143daf8b0'Done'] (active, names: '|':_UIButtonBarButton:0x143daed20 )>",
"<NSLayoutConstraint:0x280766350 H:[_UIModernBarButton:0x143daf8b0'Done']-(16)-| (active, names: '|':_UIButtonBarButton:0x143daed20 )>",

第一个你要求 Done button 在水平方向上与父视图左侧的间距是 8,第二条你要求 Done button 水平方向上距离父视图左侧的间距是 0。这肯定会冲突了。


系统已经帮你去掉了第二条,你好好检查一下你的 layout 代码。

另外这种布局叫做 VFL 语法,可以参见我以前的一篇博客。https://xuexuefeng.com/autolayout/
paullee
2019-07-09 10:52:22 +08:00
@aria955 嗯嗯,这个错误本质就是楼上大佬们提到的“约束冲突”,我看错误中包含“ UIViewAlertForUnsatisfiableConstraints ”,这个我前段时间遇到的是弹出 actionsheet (就是下边弹出的那种系统的带几个选项的空间)时,console 会提示这类型的约束错误。但是功能上又没影响,查了好多资料都说是 iOS 自己的 bug,我就没管了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/581210

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX