gpt4 book ai didi

iphone - NSGenericException',原因 : 'Unable to install constraint on view

转载 作者:太空狗 更新时间:2023-10-30 03:11:04 28 4
gpt4 key购买 nike

由于未捕获的异常“NSGenericException”而终止应用

Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint: view:; layer = ; contentOffset: {0, 0}>'

最佳答案

您需要在两个 View 中的“较高” View 上安装约束。一个好的、通用的方法是这样的:

NSLayoutConstraint* constraint = ...;
NSView* firstView = constraint.firstItem;
NSView* secondView = constraint.secondItem;
[[firstView ancestorSharedWithView: secondView] addConstraint: constraint];

请注意:这里最好记住,约束属性是在添加它们的 View 的上下文中计算的。因此,例如,对于安装在 viewB 上的约束,viewA 的 NSLayoutAttributeLeft 的值在 viewB 的坐标空间中进行解释。对于仅引用兄弟 View 或其父 View 的约束,这一事实在很大程度上是无关紧要的,但没有限制约束不能引用两个非兄弟 View 或直接父 View 的 View 。

关于iphone - NSGenericException',原因 : 'Unable to install constraint on view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14833070/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com