• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - Swift Xcode 会尝试通过打破约束来恢复吗?

[复制链接]
菜鸟教程小白 发表于 2022-12-11 18:31:42 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

当我用 Swift 4 开发我的应用程序午餐时,我在 xCode 日志上收到消息,我的 tableview 有多个不同的单元格,大约 12 个不同的单元格,我收到的警告消息是:

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2017-08-21 09:27:57.404497+0300 muzeit[6449:2211903] [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:0x174481770 V:|-(0)-[UIImageView:0x107a09eb0]   (active, names: '|':UIView:0x107a09d10 )>",
    "<NSLayoutConstraint:0x174481860 V:[UIImageView:0x107a09eb0]-(-60)-|   (active, names: '|':UIView:0x107a09d10 )>",
    "<NSLayoutConstraint:0x1744818b0 UIImageView:0x107a09eb0.centerY == UIView:0x107a09d10.centerY   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1744818b0 UIImageView:0x107a09eb0.centerY == UIView:0x107a09d10.centerY   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2017-08-21 09:27:57.492890+0300 muzeit[6449:2211903] [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:0x17048b770 V:|-(0)-[UIImageView:0x107a30c30]   (active, names: '|':UIView:0x107a30a90 )>",
    "<NSLayoutConstraint:0x17048b860 V:[UIImageView:0x107a30c30]-(-60)-|   (active, names: '|':UIView:0x107a30a90 )>",
    "<NSLayoutConstraint:0x17048b8b0 UIImageView:0x107a30c30.centerY == UIView:0x107a30a90.centerY   (active)>"
)

我试图用谷歌搜索它以找到一些解决方法,我找不到明确的答案,而且断点也没有显示约束有问题!

有什么想法吗?



Best Answer-推荐答案


如果您想更好地了解日志试图告诉您的内容,您可以查看 Visual Format Language .您可以按如下方式“翻译”您的日志:

V:|-(0)-[UIImageView:0x107a09eb0] = 在父 View 的顶部 (|) 和 ImageView 之间设置一个 0 点的垂直 (V 空间

V:[UIImageView:0x107a09eb0]-(-60)-| = 在 UIImageView 底部和父 View (|) 之间设置 -60 点的垂直 (V 空间

UIImageView:0x107a09eb0.centerY == UIView:0x107a09d10.centerY (active) = 垂直居中 UIImageView 到 superview

通过翻译,现在更容易理解你的 UIImageView 被固定在顶部和底部,这与第三个约束冲突,即试图垂直居中 UIImageView。

正如@ReinerMeilan 在评论中所建议的,您可以删除 centerY 约束来解决此自动布局问题。

关于ios - Swift Xcode 会尝试通过打破约束来恢复吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45790601/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap