ios - 有没有办法隐藏 UITableView 的页脚?
问题描述
我有一个在视图控制器内部的表格视图,表格视图根据动态单元格调整大小,有时只有 1 行,有时更多,问题是表格视图的页脚占用了大量空间,我希望页脚hide,我尝试使用委托方法viewForFooterInSection,并在viewdidload方法中将页脚高度设置为0,在heightForFooterInSection中设置为1.0,页脚仍在显示,这是tableview的照片,我将页脚背景设置为黑色检查它在哪里
override func viewDidLoad() {
super.viewDidLoad()
let notificationName = Notification.Name(rawValue: "ErrorGettingReportDetail")
NotificationCenter.default.addObserver(self, selector: #selector(self.mostrarErrorDetalle), name: notificationName, object: nil)
// Do any additional setup after loading the view.
/*self.backView.layer.cornerRadius = 10
self.backView.layer.masksToBounds = true*/
self.backScrollView.layer.cornerRadius = 10
self.backScrollView.layer.masksToBounds = true
self.commentTextView.delegate = self
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissCommentsPopUp")
view.addGestureRecognizer(tap)
self.tagsTableView.dataSource = self
self.commentTextView.autocorrectionType = .no
self.tagsTableView.estimatedRowHeight = 40
self.tagsTableView.rowHeight = UITableViewAutomaticDimension
}
这是我用于表格视图的代码:
//MARK: -TagsTableView
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(self.reporte != nil){
if((self.reporte?.atributosInfo?.count)! > 0){
return (self.reporte?.atributosInfo?.count)!
}else{
//self.tagsTableView.isHidden = true
return 0
}
}else{
return 0
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if(KRProgressHUD.isVisible){
KRProgressHUD.dismiss()
}
if(self.reporte != nil){
let cell = tableView.dequeueReusableCell(withIdentifier: "atributoCell") as! AtributoTableViewCell
let atributosInfo = self.reporte?.atributosInfo![indexPath.row]
cell.configureCellWith(atributoInfo: atributosInfo!)
cell.atributo = atributosInfo
print(indexPath.row)
let height = cell.frame.height
self.tagsTableViewHeight.constant += height
return cell
}else{
let cell = UITableViewCell()
//self.tagsTableViewHeight.constant -= cell.frame.height
return cell
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
//MARK END
任何帮助将不胜感激。
解决方案
请使用这个
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return .leastNonzeroMagnitude
}
推荐阅读
- mysql - 如何更改mysql目录(并重新启动mysql)?
- laravel - laravel 视频不在公共文件夹中
- python - 如何将 Python 日期时间转换为 JSON 格式?
- hyperledger - 超级账本作曲家导入身份 optsmspid 错误
- c# - 事务范围内对 SQL Server 的多个异步查询
- excel - 使用 Worksheet_Change 事件在 Excel 单元格的右边缘添加冒号字符
- javascript - p5鼠标跟随
- google-app-maker - 多选建议框?
- php - ajax上传文件后不显示响应消息
- python - 如何评估均方误差 (MSE) 是否合理?