快速显示和隐藏MBprogressHUD倍增时间

时间:2019-03-07 12:46:55

标签: swift mbprogresshud

一个函数以块为单位进行乘法运算。我想在完成任务时隐藏平显,并显示下一个任务的平显。但它首先显示平视,最后将其隐藏。有什么问题? 这是我的代码:

@IBAction func syncBtn(_ sender: Any) {

        let loadingNotification = MBProgressHUD.showAdded(to: view, animated: true)
        loadingNotification.mode = MBProgressHUDMode.indeterminate
        loadingNotification.label.text = "Syncing with server..."
        myAPI.SendInspectResultGetMaterials { (materials, result) in
            if result {
                MBProgressHUD.hide(for: self.view, animated: true)
                let loadingNotification = MBProgressHUD.showAdded(to: self.view, animated: true)
                loadingNotification.mode = MBProgressHUDMode.indeterminate
                loadingNotification.label.text = "Generating Database..."

                self.GenerationTheDatabase(materials: materials!, Completion: { result in

                        self.myAPI.GetSetVals { (setvals) in
                            _ = RealmService.shared.deleteAllFromObject(RealmSetVals())
                            for item in setvals.value {
                                let newSetVal = RealmSetVals(Id: item.id, ReasonType: item.type, Name: item.name)
                                _ = RealmService.shared.create(newSetVal)
                            }
                            self.myAPI.GetUserInfo(Completion: { (userInfo) in


                                MBProgressHUD.hide(for: self.view, animated: true)
                                let aDipach = DispatchQueue.global(qos: .background)
                                aDipach.async {
                                    DispatchQueue.main.async {
                                        SVProgressHUD.showSuccess(withStatus: "Synced Successfully")
                                    }
                                }
                            })

                        }

                })
            }
            else{
                MBProgressHUD.hide(for: self.view, animated: true)
                let aDipach = DispatchQueue.global(qos: .background)
                aDipach.async {
                    DispatchQueue.main.async {
                        SVProgressHUD.showError(withStatus: "Error while syncing")
                    }
                }
            }


        }

    }

我知道使用hud我必须在代码中使用块,但我做到了,但是直到最后都无法使用

0 个答案:

没有答案