如何在 moya swift 中添加进度视图?
how to add progress view in moya swift?
如何在 moya 中添加进度视图 swift ?,
这个对吗。这是使用进度块的正确方法吗?
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
if response.completed{
self.view.hideLoadingHUD()
}else{
self.view.showLoadingHUD()
}
}) { (result) in
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
self.view.hideLoadingHUD()
}
}
只需修改成功或失败块中的hideLoadingHud
即可。 bz 那部分结果处理程序
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
}) { (result) in
self.view.hideLoadingHUD()
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
}
}
您可以简单地将 LoadingHUD
隐藏在结果闭包中
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
// You can update the progress percent ...here or ignore it
}) { (result) in
self.view.hideLoadingHUD()
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
}
}
如何在 moya 中添加进度视图 swift ?, 这个对吗。这是使用进度块的正确方法吗?
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
if response.completed{
self.view.hideLoadingHUD()
}else{
self.view.showLoadingHUD()
}
}) { (result) in
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
self.view.hideLoadingHUD()
}
}
只需修改成功或失败块中的hideLoadingHud
即可。 bz 那部分结果处理程序
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
}) { (result) in
self.view.hideLoadingHUD()
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
}
}
您可以简单地将 LoadingHUD
隐藏在结果闭包中
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
// You can update the progress percent ...here or ignore it
}) { (result) in
self.view.hideLoadingHUD()
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
}
}