在以下位置创建单元格时:
func tableView ( tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath ) -> UITableViewCell
事实证明cell.constraints.count
等于0,即使包含单元格布局的xib包含它们。实现以下两个功能 - 我想象可能会在适当的时刻调用 - 产生类似的令人失望的结果:
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath)
如果我无法访问约束,我怎么能更改?
我在这做错了什么,拜托?谢谢。
答案 0 :(得分:1)
在IBOutlet
课程中为您constraint
制作UITableViewCell
,然后在cellforrowatindexpath
方法中进行更改。
例如:cellforrowatindexpath
cell.texlabel.topspace.constant = 100;
答案 1 :(得分:1)
尝试使用
cell.contentView.constraints
对我有用!