具有自动布局模式的IOS 6。
我有带有自定义UITableViewCell的UITableView。
它具有两个UILabel(标题和状态)
当项目状态为空时,我需要将状态约束宽度设置为零,以将其隐藏。我该怎么做?
我正在使用以下技术访问UITableViewCell内的标签。
UIView *status = (UIView*)[cell.contentView viewWithTag:10];
status.text=@"Sample text";
我找到了一种在UITableViewCell中访问元素约束的解决方案
1st我是子类UITableViewCell
然后添加IBOutlet
@interface UICustomTableViewCell : UITableViewCell
{
IBOutlet NSLayoutConstraint* statusWidth;
}
@property(nonatomic,retain)NSLayoutConstraint *statusWidth;
@end
然后将其分配给情节提要上的单元格原型,并使用IBOutlet链接状态宽度约束
现在,当我出队时
UICustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
我能够将状态约束设置为零。
cell.statusWidth = 0;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句