我想在线程中打开文件,这里是我的代码:试图提出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
链接没有解决我的问题,我做了很长的搜索之前发布问题 –