如何确定数据是否已使用firebase完成加载swift
我试图在从firebase firestore检索数据时实现加载屏幕。如何确定数据是否已完全加载,以便用户不会盯着空白页?这是我在一个应用程序中所做的。将此功能添加到项目中如何确定数据是否已使用firebase完成加载swift,swift,firebase,google-cloud-firestore,Swift,Firebase,Google Cloud Firestore,我试图在从firebase firestore检索数据时实现加载屏幕。如何确定数据是否已完全加载,以便用户不会盯着空白页?这是我在一个应用程序中所做的。将此功能添加到项目中 func startLoadingAlert() { let alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .alert) let loadingIndicator = UIActivityIn
func startLoadingAlert() {
let alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .alert)
let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
loadingIndicator.hidesWhenStopped = true
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
loadingIndicator.startAnimating()
alert.view.addSubview(loadingIndicator)
self.opQueue.addOperation {
OperationQueue.main.addOperation({
self.present(alert, animated: true, completion: nil)
})
}
}
在开始从firebase获取数据之前,在调用此函数。在通话结束时添加此项
self.dismiss(animated: true, completion: nil)
这取决于加载数据的方式。如果你表现得很好,很可能有人能帮助你前进。谢谢!作品优美:)我真的很感激!