下載完成后,當用戶單擊警報彈出視窗中的關閉按鈕時,我將顯示下載已完成的警報 self.quickLook(url: url) func 將呼叫。但未在 webView 中顯示該檔案。洗掉警報代碼時,一切正常并在 webView 中打開檔案。
func showAlerts(){
let alertController = UIAlertController(title: "Download", message: "Download Completed", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "dismiss", style: .default, handler: { _ in
self.dismiss(animated: true, completion: nil)
}))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(alertController, animated: true, completion: nil)
}
@IBAction func openDoc(_ sender: UIButton) {
if let url = URL(string: "https://ikddata.ilmkidunya.com/images/books/12th-class-chemistry-chapter-10.pdf") {
self.loadFileAsync(url: url) { response, error in
if error == nil {
self.showAlerts()
self.quickLook(url: url)
}
}
}
}
檢查控制臺截圖 控制臺截圖見 msg
uj5u.com熱心網友回復:
你的quickLook實施如何?我猜它也叫present. 你不能在 iOS 上同時呈現兩件東西。
一個選項是quickLook在警報被解除之后。就像是:
func showAlerts(and onDismiss: (() -> Void)? = nil) {
let alertController = UIAlertController(title: "Download", message: "Download Completed", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "dismiss", style: .default, handler: { _ in
self.dismiss(animated: true) { onDismiss?() }
}))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
present(alertController, animated: true, completion: nil)
}
@IBAction func openDoc(_ sender: UIButton) {
if let url = URL(string: "https://ikddata.ilmkidunya.com/images/books/12th-class-chemistry-chapter-10.pdf") {
loadFileAsync(url: url) { response, error in
if error == nil {
self.showAlerts { self.quickLook(url: url) }
}
}
}
}
從你的話來看,這正是你所期望的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/466463.html
下一篇:如何從檔案中獲取數字
