【发布时间】:2016-12-21 08:28:17
【问题描述】:
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return leadername.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "leadCell") as! LeaderBoardTableViewCell
cell.leaderNameLbl.text = leadername[indexPath.row]
cell.areaLbl.text = areaName[indexPath.row]
cell.approvalLabel.text = approvalrate[indexPath.row]
cell.leaderImageView?.image = UIImage(named: leaderImage[indexPath.row])
cell.backgroundColor = UIColor.white
//cell.contentView.backgroundColor = transparentColor
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 85
}
我检查了许多解决方案,但没有一个对我有用。我已经更改了单元格高度、表格视图高度等。但这对我不起作用。我们怎样才能做到这一点?请帮忙。
【问题讨论】:
-
在我看来,有两种方法可以解决您的问题: 1.每个 UITableViewCell 都显示在一个部分中,因此您可以处理每个部分的空间。 2.在UITableViewCell中,将contentView设置为更小,然后显示单元格之间的空间。
-
@nynohu 如何将内容视图设置得更小?你能在我的代码中告诉我怎么做吗?
-
如果您使用用户界面,您可以将所有内容添加到 contentView 的子视图中。并且你可以控制这个 subView 的 aize 为你想要的显示。
标签: ios uitableview swift3