从UITableViewCell子视图中删除NSIBPrototypingLayoutConstraints并添加我自己的约束而不在模拟器日志中看到错误消息的正确方法是什么?
例如,我想通过添加宽度约束来动态更改UITableViewCell内UILabel的大小。我甚至都不知道这是否是首选方法。有没有办法让我找到约束并直接更新?
答案 0 :(得分:2)
您可以删除对象的所有约束,然后添加回您想要的约束。
删除它们:
[yourView removeConstraints:yourView.constraints];
然后您可以手动添加自己的约束。 (here is a more detailed link添加视图宽度约束)
只修改现有约束:
for(NSLayoutConstraint *constraint in yourView.constraints) {
//you can inspect these to see if their .firstAttribute or .secondAttribute correspond to the type of NSLayoutAttribute you are looking for.
}