您好我正在尝试在隐藏的indicatorView之后调整tableview的高度。
self.tableView.reloadData()
self.refresher.endRefreshing()
self.indicator.stopAnimating()
self.indicatorView.isHidden = true
当我将indicatorView设置为隐藏但TableView的高度仍然具有indicatorView高度的空间。
答案 0 :(得分:1)
不知何故,您需要实施tableView(_:heightForRowAt:)。例如:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// pseudo:
/*
if a condition related to hide the indicator (for example response from calling an api to get some data) is true, retrun -for example 100-, else (the response has not been called yet) retrun another value.
*/
}
您还可以查看indexPath.row
以查找特定行高:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// check if it is the second row:
if indexPath.row == 1 {
}
}
因此,在调用self.tableView.reloadData()
之后,应该调用它并为该行指定新的高度。
希望这会有所帮助。
答案 1 :(得分:1)
在堆栈视图中嵌入tableView
和indicatorView
。
与this answer类似,但与Vertical
轴一样。