如何使用swift的MBProgressHUD [英] How to use MBProgressHUD with swift

查看:734
本文介绍了如何使用swift的MBProgressHUD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

here is my code , but it showing the progress . is there any error in this code? please give some idea to fix this, or give some link related to this.

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)          
      }
   }

}


推荐答案

更新后的答案:

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

解雇ProgressHUD:

To dismiss the ProgressHUD:

MBProgressHUD.hideAllHUDs(for: view, animated: true)

这篇关于如何使用swift的MBProgressHUD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆