我想在線程中打開文件,這裏是我的代碼:試圖提出VC,其觀點是不是在窗口層次
DispatchQueue.main.async(execute: {() -> Void in
var documentsURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).appendPathComponent(「File.pdf")
self.docController = UIDocumentInteractionController.init(url: documentsURL as URL)
self.docController?.delegate = self as? UIDocumentInteractionControllerDelegate
self.docController?.presentPreview(animated: true)
self.docController?.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
})
時,主屏幕顯示移動此警告和文件無法打開
Warning: Attempt to present <_UIDocumentActivityViewController: 0x...> on <HCM.PrintVacationDecisionVC: 0x...> whose view is not in the window hierarchy!
任何有助於解決這個問題?
'PrintVacationDecisionVC'是不可見的,所以它不能呈現'UIDocumentInteractionController'。 – Larme
鏈接沒有解決我的問題,我做了很長的搜索之前發佈問題 –