t系统设置的NSAutoresizingMaskLayoutCo

t系统设置的NSAutoresizingMaskLayoutCo

本文介绍了由AutoLayout系统设置的NSAutoresizingMaskLayoutConstraint引入的神秘值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AutoLayout添加了一个NSAutoresizingMaskLayoutConstraint,它会引起冲突,目前尚不清楚在何处以及如何发生冲突.

AutoLayout is adding a NSAutoresizingMaskLayoutConstraint that causes a conflict, and it's unclear where and how.

问题是:293的高度从哪里来?

The question is: where does the height of 293 come from?

UIView层次结构:

UIView hierarchy:

自动版式日志已编号. Xcode标签未显示在AutoLayout日志中.

The AutoLayout log has been numbered. Xcode labels didn't show up in the AutoLayout logs.

第1行似乎很麻烦.根据约束,看来这是Post View Cell,这是自定义的UICollectionViewCell.

Line 1 seems to be the trouble. Based on the constraints, it seems this is Post View Cell, which is a custom UICollectionViewCell.

但是sizeForItemAt UICollectionViewDelegate函数没有返回该值.如果您将返回值硬编码为CGSize(width: 300, height: 100)之类的值,则293仍会出现在日志中.

Yet the sizeForItemAt UICollectionViewDelegate function does not return this value. If you hard code the return value to something like CGSize(width: 300, height: 100), 293 still appears in the log.

那么293是哪里来的?

So where is 293 coming from?

第2行是代码中设置的约束,这是正确的值.此视图应为Attachment View.

Line 2 is a constraint set in code, and this is the right value. This view should be Attachment View.

第3行和第4引用Post Content View,它是UIStackView.

Lines 3 & 4 refer to Post Content View, which is a UIStackView.

第5行是Text View.

第6行是Attachment View.

第7行是UIStackView(Post Content View)设置的间距.

Line 7 is the spacing set by the UIStackView (Post Content View).

1. "<NSAutoresizingMaskLayoutConstraint:0x600002a47610 h=--& v=--& UIView:0x7facf0e126b0.height == 293   (active)>",
2. "<NSLayoutConstraint:0x600002a79a40 UIView:0x7facf0e07110.height == 280   (active)>",
3. "<NSLayoutConstraint:0x600002a785a0 V:[UIStackView:0x7facf0e12890]-(10)-|   (active, names: '|':UIView:0x7facf0e126b0 )>",
4. "<NSLayoutConstraint:0x600002a79180 V:|-(10)-[UIStackView:0x7facf0e12890]   (active, names: '|':UIView:0x7facf0e126b0 )>",
5. "<NSLayoutConstraint:0x600002a7cff0 'UISV-canvas-connection' UIStackView:0x7facf0e12890.top == UITextView:0x7facf283a600'hi'.top   (active)>",
6. "<NSLayoutConstraint:0x600002a7cf00 'UISV-canvas-connection' V:[UIView:0x7facf0e07110]-(0)-|   (active, names: '|':UIStackView:0x7facf0e12890 )>",
7. "<NSLayoutConstraint:0x600002a7d270 'UISV-spacing' V:[UITextView:0x7facf283a600'hi']-(5)-[UIView:0x7facf0e07110]   (active)>"


Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002a79a40 UIView:0x7facf0e07110.height == 280   (active)>

推荐答案

只要您拥有translatesAutoresizingMaskIntoConstraintstrue的视图,NSAutoresizingMaskLayoutConstraint就会出现(不幸的是,当您在其中创建视图时,这是默认设置)代码).确保不是这种情况.

An NSAutoresizingMaskLayoutConstraint can arise any time you have a view for which translatesAutoresizingMaskIntoConstraints is true (which, unfortunately, is the default when you create a view in code). Make sure that that's not the case.

这篇关于由AutoLayout系统设置的NSAutoresizingMaskLayoutConstraint引入的神秘值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:13