找出谁添加了特定的自动布局约束
Find out who adds a specific auto layout constraint
如何找出谁添加了特定的自动布局约束?
因为我看到了一些我确定没有添加的限制。
在 Swift 你可以看看 var identifier: String?
。如果它以 NS
开头,那么它是由 iOS 添加的。
A constraint’s identifier is available in its description. Identifiers that start with NS are reserved by the system.
如果布局模棱两可或无法满足,你可以在上面放一个符号断点UIViewAlertForUnsatisfiableConstraints
.
您可以为 Objective-C 添加包含 po [[UIWindow keyWindow] _autolayoutTrace]
的 Debugger Command
或为 Swift 添加 expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
,这会自动打印 UIView
层次结构,如this article.
中描述
您还可以在调试器中使用 po $r15
为 "more detailed description of all constraints added in addition to breaking constraint" 打印 "details description of constraint that is broken" 或 po $r14
,如 this article.
中所述
如果没有,您可以设置 accessibilityIdentifier
for your UIView
(or directly in the IB) 来代替字符串 UIView
.
如何找出谁添加了特定的自动布局约束?
因为我看到了一些我确定没有添加的限制。
在 Swift 你可以看看 var identifier: String?
。如果它以 NS
开头,那么它是由 iOS 添加的。
A constraint’s identifier is available in its description. Identifiers that start with NS are reserved by the system.
如果布局模棱两可或无法满足,你可以在上面放一个符号断点UIViewAlertForUnsatisfiableConstraints
.
您可以为 Objective-C 添加包含 po [[UIWindow keyWindow] _autolayoutTrace]
的 Debugger Command
或为 Swift 添加 expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
,这会自动打印 UIView
层次结构,如this article.
中描述
您还可以在调试器中使用 po $r15
为 "more detailed description of all constraints added in addition to breaking constraint" 打印 "details description of constraint that is broken" 或 po $r14
,如 this article.
如果没有,您可以设置 accessibilityIdentifier
for your UIView
(or directly in the IB) 来代替字符串 UIView
.