【发布时间】:2017-08-11 06:54:59
【问题描述】:
我有这样的代码
startAnimating(CGSize(width: 100, height: 100), message: "Loading...", type: NVActivityIndicatorType.pacman, displayTimeThreshold: 5, minimumDisplayTime: 5)
self.view.makeToastActivity(.center)
DispatchQueue.global(qos: .background).async {
//self.view.addSubview(collectionNews)
//activityIndicatorView.stopAnimating()
DispatchQueue.main.async {
self.myGroup.enter()
self.view.isUserInteractionEnabled = false
self.view.window?.isUserInteractionEnabled = false
self.getJsonFromUrl()
self.collectionNews.dataSource = self
self.collectionNews.delegate = self
self.collectionNews.contentInset = UIEdgeInsetsMake(0, 5, 0, 5)
self.getJsonFromUrl2()
self.myGroup.leave()
self.refresh_now()
self.myGroup.notify(queue: .main) {
self.stopAnimating()
self.view.hideToastActivity()
self.view.isUserInteractionEnabled = true
self.view.window?.isUserInteractionEnabled = true
}
}
}
但是,当我运行应用程序时,活动指示器总是在所有图像加载成功之前消失。当用户在所有内容加载成功之前尝试滚动应用上的每个位置时,这将触发错误。
甚至,我使用了 2 个活动指示器,并且它们总是在加载所有内容之前消失。
谁能给我建议,我做错了哪一个?
【问题讨论】:
-
你在 tableView 中的哪里显示图像?你把这段代码放在哪里?你能让你的问题更容易理解吗?
-
你可以为活动指示器@christ2702添加时间
标签: ios swift xcode uiactivityindicatorview activity-indicator