无法设置 MBProgressHUD 模式来确定

Unable to set MBProgressHUD mode to determinate

在我正在处理的 Swift 3 项目中,我有一个带有 MBProgressHUD 的简单视图控制器。我可以让 HUD 显示,即使我设置了模式 属性 和标签的文本,我得到的只是一个旋转 UIActivityIndicator。有人知道如何解决这个问题吗?

// Property declaration
var transferHUD = MBProgressHUD()


// Configured in viewDidLoad()
transferHUD = MBProgressHUD.init(view: self.view)
transferHUD.mode = MBProgressHUDMode.determinate
transferHUD.hide(animated: false)


// from the progressUpdated function
transferHUD.progress = Float(progress.fractionCompleted)
transferHUD.label.text = "Transferring..."


// I logged the mode and this is what it said
// print("HUD mode -- \(transferHUD.mode)")
// Output == transferHUD mode -- MBProgressHUDMode


// Here is where I show it again. I've tried a few different ways, but neither way changes the appearance
DispatchQueue.main.async {
    // self.transferHUD.show(animated: true)
    MBProgressHUD.showAdded(to: self.view, animated: true)
}

当您调用 showAdded: 时,它会创建一个新的 MBProgressHUD 实例。您可以调用 show 方法或更改代码,如:

let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
hud.mode = MBProgressHUDMode.determinate
hud.label.text = "Transferring..."