你好 StackOverflowers!
我试图在满足条件时隐藏单元格 - 在这种情况下,当用户调查评论为空时。数据是从 Firebase 加载的 这是我迄今为止尝试过的:隐藏单元格以及选择它。然后对 selectedRows 使用 heightForRow。但它不起作用。请帮忙!谢谢~~~
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return comment.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CommentsTableCell", for: indexPath) as! CommentsCell
let surveyCommentList = self.comment[indexPath.row]
cell.selectionStyle = UITableViewCell.SelectionStyle.none
if surveyCommentList.surveyComment == "" {
cell.isHidden = true
cell.isSelected = true
} else {
cell.surveyCommentText.text = surveyCommentList.surveyComment
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if let selectedRows = tableView.indexPathsForSelectedRows, selectedRows.contains(indexPath) {
return 0
} else {
return 50
}
}