我使用Firebase Storage来存储图像。一切都会按预期上传,并且图像会出现在Firebase控制台上,但是由于任何原因,完成处理程序不会触发,因此进度HUD不会消失。我在第6行设置了一个断点,因此我知道完成处理程序不会触发。有人可以向我解释为什么会发生这种情况吗?
guard let imageData = imageToUpload.jpegData(compressionQuality: 0.8) else { return }
let task = spaceRef.putData(imageData, metadata: nil, completion: { (metadata, error) in
if let error = error {
print("ERROR: \(error)")
}
self.dismissProgressHUD()
})
task.observe(.progress, handler: { (snapshot) in
guard let progress = snapshot.progress else { return }
print(progress)
})
task.observe(.success, handler: { (snapshot) in
print("succes")
self.dismissProgressHUD()
})
dismissProgressHUD()是UIViewController扩展内的方法。
func dismissProgressHUD() {
DispatchQueue.main.async {
SVProgressHUD.dismiss()
}
}
控制台输出:
<NSProgress: 0x281d88140> : Parent: 0x0 / Fraction completed: 0.0000 / Completed: 0 of 2095130
<NSProgress: 0x281d88140> : Parent: 0x0 / Fraction completed: 0.0001 / Completed: 115 of 2095245
<NSProgress: 0x281d8b520> : Parent: 0x0 / Fraction completed: 0.0040 / Completed: 8307 of 2095245
<NSProgress: 0x281d8b480> : Parent: 0x0 / Fraction completed: 1.0000 / Completed: 2095245 of 2095245
2019-02-22 08:21:42.665537+0100 Binfinder[320:23087] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C11.1:2][0x1407a9660] get output frames failed, state 8196
2019-02-22 08:21:42.665806+0100 Binfinder[320:23087] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C11.1:2][0x1407a9660] get output frames failed, state 8196
2019-02-22 08:21:42.666331+0100 Binfinder[320:23087] TIC Read Status [11:0x0]: 1:57
2019-02-22 08:21:42.666368+0100 Binfinder[320:23087] TIC Read Status [11:0x0]: 1:57
答案 0 :(得分:0)
我已经将CocoaPods更新到了最新版本,现在一切正常。