gpt4 book ai didi

ios - 以编程方式添加约束给我错误

转载 作者:行者123 更新时间:2023-11-29 12:22:31 25 4
gpt4 key购买 nike

我正在尝试以编程方式将左右 NSLayoutConstraint 添加到 view。这是我的代码:

[self.mainView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-2.5-[_otherView]-2.5-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(self.otherView)]];

运行应用程序时出现以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: 

_otherView is not a key in the views dictionary.

最佳答案

NSDictionaryOfVariableBindings 的参数应该是 _otherView

它必须是与您在约束视觉格式中引用它的方式完全匹配的字符串。

关于ios - 以编程方式添加约束给我错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30178542/

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