我在iOS应用程序中使用SVProgressHUD并且它运行正常。我也想将它用于此应用的共享扩展,但它不会显示应用。 我使用自定义视图进行共享扩展视图,这是我用来调用SVProgressHUD的代码。请注意,打印上载进度正常。 我究竟做错了什么? 感谢。
class ShareViewController: UIViewController {
...
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(jpgImageData!, withName: "file",fileName: fname, mimeType: "image/jpg")
for (key, value) in parameters {
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
},
to:url!)
{ (result) in
switch result {
case .success(let upload, _, _):
upload.uploadProgress(closure: { (progress) in
print("Upload Progress: \(progress.fractionCompleted)")
SVProgressHUD.setViewForExtension(self.view)
SVProgressHUD.showProgress(Float(progress.fractionCompleted))
})
upload.responseJSON { response in
if response.response?.statusCode == 200{
if let result = response.result.value {
DispatchQueue.main.async(execute: {
let pre = NSLocale.preferredLanguages[0]
var message = "Message"
SVProgressHUD.showSuccess(withStatus: message)
SVProgressHUD.dismiss(withDelay: 2)
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
})
}
答案 0 :(得分:0)
试试这个
class ShareViewController: UIViewController {
...
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(jpgImageData!, withName: "file",fileName: fname, mimeType: "image/jpg")
for (key, value) in parameters {
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
},
to:url!)
{ (result) in
switch result {
case .success(let upload, _, _):
upload.uploadProgress(closure: { (progress) in
print("Upload Progress: \(progress.fractionCompleted)")
DispatchQueue.main.async(execute: {
SVProgressHUD.setViewForExtension(self.view)
SVProgressHUD.showProgress(Float(progress.fractionCompleted))
})
})
...
}