在以下位置创建单元格时:
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)
如果我无法访问约束,我怎么能更改它们?
请问我做错了什么?谢谢。
最佳答案
在 UITableViewCell
类中为您制作 IBOutlet
constraint
,然后在 cellforrowatindexpath
方法中进行更改。
例如:在cellforrowatindexpath
cell.texlabel.topspace.constant = 100;
关于ios - 如何以编程方式更改 UITableViewCell 上的约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38694986/