ios - 部分滑动单元格后,表格视图单元格高度缩小
问题描述
使用 SwipeCellKit 的表视图控制器
使用设置行高
cell.textLabel?.numberOfLines = 0 //allows row size to expand
cell.textLabel?.lineBreakMode = .byWordWrapping
也试过:
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = UITableView.automaticDimension
当我打开 tableviewcontroller 时,单元格高度是正确的。当我向左滑动但再次单击时决定不删除单元格时,单元格大小将缩小为两行。如果我离开表格视图控制器并回来,单元格高度再次正确。
视频示例:https ://drive.google.com/file/d/1tbJb0XrrjWQ3An-bc_XdZfPPNLg6tXlD/view?usp=sharing
解决方案
尝试这个:
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 270
给出estimatedRowHeight
更高的值而不是使用UITableView.automaticDimension
将下表视图委托方法添加到您的代码中:
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
希望在情节提要中,您top, bottom, leading and trailing
为单元格内的标签提供了适当的 ( ) 约束。
推荐阅读
- api - 可以将安全组添加到 slcli order place 命令
- tableau-api - 如何在提取数据 Tableau 上使用字段名称?
- image-processing - 不同图像大小的迁移学习(VGG、ResNet)
- python - 为什么 pip install MySQL-python==1.2.5 因 C 编译错误而失败?
- sql-server - 要在视图中使用的 SQL Pivot
- android - 什么是 Mono 共享运行时?
- python - 设置 pip 安装程序使用的 C 编译器标志
- python - 在所有 IDE 中安装模块
- python - 通过 python 自动化 .get 请求
- bluetooth - 从写入读取响应的解决方法