一尘不染

如何快速使用MBProgressHUD

swift

这是我的代码,但显示了进度。这段代码有什么错误吗?请提供一些想法来解决此问题,或者提供一些与此相关的链接。

class Approval: UIViewController {

var hud: MBProgressHUD = MBProgressHUD()

override func viewDidLoad() {
    super.viewDidLoad()

    fetchData()
}
   func fetchData(){
      hud.show(true)
      // doing some http request
      dispatch_async(dispatch_get_main_queue()) {
         hud.hide(true)          
      }
   }

}

阅读 300

收藏
2020-07-07

共1个答案

一尘不染

更新的答案:

let loadingNotification = MBProgressHUD.showAdded(to: view, animated: true)
loadingNotification.mode = MBProgressHUDMode.indeterminate
loadingNotification.label.text = "Loading"

要关闭ProgressHUD:

MBProgressHUD.hideAllHUDs(for: view, animated: true)
2020-07-07