我在我的项目中通过 pod 集成了 Alamofire
、SwiftyJson
和 AlamofireNetworkActivityIndicator
框架。按照 Github 页面中给出的说明操作后,AlamofireNetworkActivityIndicator 未显示。
https://github.com/Alamofire/AlamofireNetworkActivityIndicator
它表示事件指示器工作所需的全部是以下代码行:
NetworkActivityIndicatorManager.shared.isEnabled = true
我基本上只需要一个事件指示器来显示何时发出请求或正在加载数据(Alamofire 方法)
最佳答案
其实你误会了 AlamofireNetworkActivityIndicator
并不是像 MBProgressHUD
或 SVProgressHUD
这样的 UIActivityIndicator
。当有 API 调用时,它会在状态栏中显示一个微调框。
这将用于显示 NetworkActivityIndicatorManager.shared.isEnabled = true
,false
将从状态栏中隐藏。
//Using MBProgressHUD
//Show indicator
MBProgressHUD.showHUDAddedTo(self.view, animated: true)
Alamofire.request(.POST, URL, parameters: parameter, encoding: .JSON)
.responseJSON { response in
//Hide indicator
MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
}
关于iphone - AlamofireNetworkActivityIndicator 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41711658/