【发布时间】:2013-12-01 21:08:12
【问题描述】:
我想在 cellForRowAtIndexPath 中添加一些视图到我的单元格内容视图并为它们添加约束,但没有任何效果。我有这样的事情:
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:imageView
attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeLeft multiplier:1.0f constant:10.0f];
[cell.contentView addConstraint:constraint];
我应该怎么做?
【问题讨论】:
-
您是否使用手动添加到单元格的图像视图来执行此操作?在添加自己的控件时,我建议不要使用现有
imageView属性的名称(例如,imageView、textLabel和detailTextLabel)。或者您是否尝试在现有的imageView上执行此操作,我也不建议这样做。 -
不,这只是示例名称,我为图像视图使用了另一个名称。
标签: ios autolayout