美文网首页iOS新手学习iOS
iOS 使用Masonry出现约束警告问题

iOS 使用Masonry出现约束警告问题

作者: Sim_Liu | 来源:发表于2019-05-09 16:52 被阅读0次

在使用Masonry时候,有时候虽然界面显示正常,但是log里面会出现如下类似的警告。


一.问题描述:

[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. 

[

<MASLayoutConstraint:0x600002e4db00 UIImageView:0x7f8510f5ec00.left == OTCMyHeaderView:0x7f8510d11da0.left + 14>,

<MASLayoutConstraint:0x600002e4db60 UIImageView:0x7f8510f5ec00.right == OTCMyHeaderView:0x7f8510d11da0.right - 14>,

<NSLayoutConstraint:0x600002962080 OTCMyHeaderView:0x7f8510d11da0.width == 0>

]

Will attempt to recover by breaking constraint 

<MASLayoutConstraint:0x600002e4db60 UIImageView:0x7f8510f5ec00.right == OTCMyHeaderView:0x7f8510d11da0.right - 14>

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.

1

二. 解决方法:

1.通过断点找到有问题的控件XX

2. 初始化控件XX 下面 添加 代码   MASAttachKeys(控件XX)

2

3.run,看log

3

一目了然就可以看到有问题的约束,修改即可。

相关文章

  • iOS 使用Masonry出现约束警告问题

    在使用Masonry时候,有时候虽然界面显示正常,但是log里面会出现如下类似的警告。 一.问题描述: [Layo...

  • iOS中的一些常见问题,和解决方法

    1.Masonry 的使用, 当出现一堆约束警告的时候, 无法判断是哪个View 出现了约束问题的时候可以使用 M...

  • iOS Masonry使用笔记

    关于在使用Masonry中遇到的问题 一、约束警告 上面的问题是由于系统判定代码和编辑器中可能出现了重复约束,可以...

  • iOS 消除警告整理

    一、约束警告 在使用Masonry的时候经常与遇到下面的警告日志 上面的问题是由于系统判定代码和编辑器中可能出现了...

  • Autolayout

    约束优先级问题使用Masonry 约束优先级问题 使用Masonry 一行两个Label,距离屏幕左右边距各15,...

  • UIScrollView 使用 Masonry 添加约束实现滚动

    项目中经常使用到 UIScrollView,在使用 Masonry 添加约束时,经常会出现奇怪的问题,比如 UIS...

  • Masonry适配safeArea

    我这里讲解使用的是Masonry,我假设你对约束有一定的了解。 随着iPhone X的出现,iOS页面的适配似乎也...

  • Masonry解析

    Masonry 、 AutoLayout 、 约束 、 三方库 、 iOS MagicNumber -> ...

  • Masonry使用方法

    Masonry的使用 Masonry的github地址 Masonry的基本使用方法 给控件添加约束使用Mason...

  • iOS根据对象的内存地址找到对应的类

    大家在使用自动布局的时候,经常一不小心会出现约束警告,log如下: 我们需要知道哪些对象的约束出现了问题,可以在当...

网友评论

    本文标题:iOS 使用Masonry出现约束警告问题

    本文链接:https://www.haomeiwen.com/subject/mtqgoqtx.html