我正在使用带有动态单元格的 UITableView。每个单元格都有一些按钮、一个图像和一个标签。图像的宽度等于 tableview 的宽度,高度是可变的。
我正在通过函数更新 cellForRowAtIndexPath 中图像的高度...以尊重纵横比。标签可以有 1 行或多行。
我正在使用 heightForRowAtIndexPath 来设置单元格的高度。我在那里计算并返回值。
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let queficient = CGFloat(dataController.Data[indexPath.row].width) / self.view.frame.size.width
let imgHeight = CGFloat(dataController.Data[indexPath.row].height) / queficient
return 134 + imgHeight + heightForView(dataController.Data[indexPath.row].description)
}
我不知道为什么当我滚动时表格有点迟钝和跳跃。