ios - PrototypeCell 上的空白区域
问题描述
我UITableView
有 2 个部分,第一个是显示 a SegmentControl
,第二个是显示我的数据。第 2 部分还可以,但在 SegControl 部分,组件不适合正确的高度。
故事板
结果:空白区域出现在UISegmentedControl
单元格下方。
我尝试了很多方法来解决这个问题:
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 1 {
return 100
}
return 44.0
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.0
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == 0 {
return nil
}
.
.
}
编辑
我发现这个空白是页脚,但我不知道如何隐藏它。
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
view.backgroundColor = UIColor.red
return view
}
解决方案
更新:添加额外空间的是节页脚视图,而不是单元格本身。
使用heightForFooterInSection
. 以下代码应该能够解决您的问题。
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 0 {
return 0
}
return UITableView.automaticDimension
}
推荐阅读
- c# - 无法加载文件或程序集 Microsoft.AspNetCore.Http.Abstractions,版本 = 5.0.0.0,
- sql - Oracle中根据id生成重复行
- python - Json split python 大文件内存问题
- windows-10 - Windows 10:可以重置键盘布局吗?
- apache-spark - Apache Spark SQL 无法选择 Cassandra 时间戳列
- memory - .NET - 进程的最大可能内存分配大小?
- python - NLP-我们如何在神经网络中输入 FastText 的输出
- airflow - airflow create sub process based on number of files
- flutter - 搜索列表时,gridview builder中的空容器占用空间
- node.js - 为一个 SQS 使用多个 lambda 触发器