ios - 无法设置 MBProgressHUD 模式来确定

标签 ios swift mbprogresshud

在我正在开发的 Swift 3 项目中,我有一个带有 MBProgressHUD 的简单 View Controller 。我可以显示HUD,即使我设置了模式属性和标签文本,我得到的只是一个旋转的UIActivityIndi​​cator。有人知道如何解决这个问题吗?

// 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..."

关于ios - 无法设置 MBProgressHUD 模式来确定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43077837/

相关文章:

ios - MBProgressHUD 和 UITableView

ios - 使用 UINavigationController 管理 UIViewController 层次结构

ios - 没有修饰符标志的键盘命令——Swift 2

swift - 停止 urlRequest onViewDisappear

iphone - MBProgressHUD 没有停止

ios - MBProgressHUD 与 Swift、Fabric 和 TwitterKit

ios - 如何停止来自应用程序的通知

ios - Swift - 如何检查 firestore 文档是否存在?

swift - 如何在 Swift 中声明类级别的函数?

ios - 将图像从 ScrollView 拖到 UIView 中