【发布时间】:2018-03-08 09:55:00
【问题描述】:
【问题讨论】:
-
实现方法 heightForRowAtIndexPath 并根据您的要求返回高度。
标签: ios swift uitableview
【问题讨论】:
标签: ios swift uitableview
您可以通过将约束添加到单元格内的标签或将其添加到您的viewDidLoad 来更改单元格的高度:
tableView.rowHeight = 40
或者您可以添加以下委托函数来更改高度:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 40
}
【讨论】:
您可以使用 tableView 委托方法并为您的 heightForRowAt 指定值
说你希望它是 80:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return CGFloat(80)
}
【讨论】:
接受的答案对我不起作用。对我有用的是在以下委托下添加 tableview rowheight:
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
tableView.rowHeight = 350
【讨论】: