如何在 swift 中的登录请求中显示加载
how to show loading at the login request in swift
当登录过程类型为Post
使用 Alamofire
我想在等待服务器时显示登录进度
.....
例如上面的视图,当你按下登录按钮时登录界面出现,当你进入主界面时消失
此解决方案无效:::
func show () {
let alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .alert)
let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
loadingIndicator.hidesWhenStopped = true
loadingIndicator.style = UIActivityIndicatorView.Style.gray
loadingIndicator.startAnimating();
alert.view.addSubview(loadingIndicator)
vc.present(alert, animated: true, completion: nil)
// vc.dismiss(animated: false, completion: nil)
}
如果要使用 CocoaPods,请使用 https://cocoapods.org/pods/SVProgressHUD
要使用它,请调用 SVProgressHUD.show()
在发送 http 请求之前,然后在登录成功后调用 SVProgressHUD.dismiss() 。
希望对您有所帮助。
干杯。
当登录过程类型为Post 使用 Alamofire
我想在等待服务器时显示登录进度
.....
例如上面的视图,当你按下登录按钮时登录界面出现,当你进入主界面时消失
此解决方案无效:::
func show () {
let alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .alert)
let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
loadingIndicator.hidesWhenStopped = true
loadingIndicator.style = UIActivityIndicatorView.Style.gray
loadingIndicator.startAnimating();
alert.view.addSubview(loadingIndicator)
vc.present(alert, animated: true, completion: nil)
// vc.dismiss(animated: false, completion: nil)
}
如果要使用 CocoaPods,请使用 https://cocoapods.org/pods/SVProgressHUD
要使用它,请调用 SVProgressHUD.show() 在发送 http 请求之前,然后在登录成功后调用 SVProgressHUD.dismiss() 。
希望对您有所帮助。
干杯。