【发布时间】:2018-07-24 05:38:27
【问题描述】:
所以我尝试在 tableview 加载所有数据之前添加一个指标,所以我用谷歌搜索了它,我找到了以下代码并且效果很好:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if let lastVisibleIndexPath = tableView.indexPathsForVisibleRows?.last {
if indexPath == lastVisibleIndexPath {
indicator.stopAnimating()
}
}
但问题是它仅在我有数据要加载或有单元格要显示时才有效,当没有数据或没有单元格时,指示器会停留在那里并继续旋转。谁能告诉我如何解决这个问题。非常感谢!
【问题讨论】:
-
异步加载模型对象并显示活动指示器。在完成块中停止动画活动指示器。如果您需要示例,请分享您加载数据模型的代码 sn-p。
-
你能说明你在哪里调用你的网络服务来获取数据吗?
-
如何收集表格数据?可以出示一下代码吗?