ios swift tableView根据数据显示隐藏cell
思路
先把cell展示出来,如果需要隐藏就行高返回0,并且隐藏cell
代码
- tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if isLightControl {cell.isHidden = false}else {cell.isHidden = true}
- tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
if isLightControl == false {return 0}return 55
- 为了保持.insetGrouped类型tableView, section的圆角,row+1, 行高返回10