【发布时间】:2015-12-14 10:59:41
【问题描述】:
这是我下面给出的代码:
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(cell.lblname);
NSLog(@"%@",viewsDictionary);
NSArray *constra= [NSLayoutConstraint constraintsWithVisualFormat:@"|-10-[cell.lblname]-10-|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:viewsDictionary];
//Work through the array of constraints, applying each to the superview
for (int i = 0; i<constra.count; i++) {
[cell.contentView addConstraint:constra[i]];
}
这就是我得到的
2015-12-14 16:23:34.846 hello[2354:102290] {
"cell.lblname" = "<UILabel: 0x7fd6a1cb7a80; frame = (0 0; 318 40); userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fd6a1cf4610>>";
}
2015-12-14 16:23:34.898 hello[2354:102290] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
cell is not a key in the views dictionary.
|-10-[cell.lblname]-10-|
^'
如何解决这个问题帮助我,我是视觉约束的新手......
【问题讨论】:
-
您的标签的属性名称是什么?是
lblname吗? -
@AndréSlotta property (nonatomic ,retain) UILabel *lblname;
标签: ios objective-c constraints