ios - 如何快速将我的部分页脚粘贴在表格视图中一个特定页脚的末尾
问题描述
我在这里有一些部分,在第 1 部分,我有这个页脚作为附加信息。但是当我滚动屏幕时它会一直浮动。我该如何阻止它?如何将其保留在该部分下?我正在使用viewForFooterInSection
,这是我的代码:
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let footerView = UIView()
if section == 1 {
let label = UILabel()
label.text = "A sticky footer here..."
label.font = .systemFont(ofSize: 16)
label.textColor = UIColor.gray
label.backgroundColor = UIColor.clear
label.textAlignment = .left
footerView.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 10).isActive = true
label.leftAnchor.constraint(equalTo: footerView.leftAnchor, constant: 20).isActive = true
label.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true
label.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true
}
return footerView
}
我想保持粘性,在我的第 1 部分下。我该怎么做?
先感谢您
解决方案
您应该使用分组样式初始化表格视图。
let tableView = UITableView(frame: .zero, style: .grouped)
推荐阅读
- excel - 如何复制隐藏的工作表并且新复制的工作表不隐藏?
- python - 我无法使用 Django-Rest-Framework 注册用户
- php - 一种在 PHP 中折叠对象数组的简写方法
- c - C是整数数学等价于无符号数学?
- python - 为什么我的 fastapi 或 uvicorn 会被关闭?
- python - 如何在 VS Code 终端中从 .py 文件运行多个 django python 脚本?
- certificate - 使用 HyperLedger Fabric 证书签署消息
- php - PHP中列的总和给出错误的输出
- r - 合并大型数据集
- css - CSS 背景 url 图像在较大的分辨率下看起来很模糊,但在较小的屏幕分辨率下看起来很清晰