当我选择自定义单元格时,我试图调整标签高度的大小(以使其扩展以使更多文本可见)。
我显然缺少一些基本的东西,因为在尝试绘制新的CGRect之后,框架是完全相同的。
以下是相关代码:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let indexPath = tableView.indexPathForSelectedRow()
let currentCell = tableView.cellForRowAtIndexPath(indexPath!) as! BasicCell
UIView.animateWithDuration(0.3) {
tableView.beginUpdates()
currentCell.subtitleLabel!.frame = CGRectMake(currentCell.subtitleLabel!.frame.origin.x, currentCell.subtitleLabel!.frame.origin.y, currentCell.subtitleLabel!.frame.size.width, 100)
currentCell.subtitleLabel!.numberOfLines = 0
tableView.endUpdates()
}
}
任何帮助,将不胜感激。
你应该用
-reloadRowsAtIndexPaths:withRowAnimation:
内部beginUpdate
和endUpdate
配对。仅仅设置框架不足以使表视图知道需要更新哪个单元格。
同样,也不需要将更新代码放入动画块中。它具有固有的动画效果。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句