哪个时候为superView添加约束?

时间:2017-06-21 09:46:41

标签: ios objective-c autolayout constraints

我想在没有Xib和Storyboard的Aview Aview.superView上添加约束,我在函数-(void)didMoveToSuperview中添加约束代码,它有效。我第二次将Aview添加到cell.contentView,当我开始滚动时,它崩溃了;
这是错误信息:
A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs
但我相信乘数的所有参数都不是0或零。 似乎第二项(superView)是nil,所以我在这样的自定义函数中编写约束代码:

[cell.contentView addSubview:view];
[view setConstraint];

然后它起作用;
我只想知道在Aview中添加约束有什么好方法吗?在哪个函数中?

0 个答案:

没有答案