UIDocumentInteractionController on iphoneX with iOS 11.1.2

When I use the UIDocumentInteractionController on iphoneX with iOS 11.1.2, it does not appear and logs in to the console as:

[ShareSheet] ERROR: <_UIDICActivityViewController: 0x107075c00> timed out waiting to establish a connection to the ShareUI view service extension. 

but the same code works fine on another device with iOS 11.1.2, only iphoneX cannot view the documentInteraction menu. Is there something wrong with my code? Please tell me if you find a solution.

My code is:

  var doc: UIDocumentInteractionController? fileprivate func openWithOtherApp(with url: URL) -> Void { let doc = UIDocumentInteractionController(url: url) self.doc = doc doc.delegate = self DispatchQueue.main.async { [weak self] in guard let weakSelf = self else { return } if weakSelf.doc?.presentOpenInMenu(from: weakSelf.view.bounds, in: weakSelf.view, animated: true) != true { Toast(message: "No app on you iPhone can open this file.") } } } 

delegate:

  extension UniversalPreviewController: UIDocumentInteractionControllerDelegate { func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController { return self } func documentInteractionControllerRectForPreview(_ controller: UIDocumentInteractionController) -> CGRect { return self.view.bounds } func documentInteractionControllerViewForPreview(_ controller: UIDocumentInteractionController) -> UIView? { return self.view } func documentInteractionControllerWillBeginPreview(_ controller: UIDocumentInteractionController) { NSLog("documentInteractionControllerWillBeginPreview") } func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) { self.doc = nil } } 

My last test:

When I use the constant URL of the file (drag the file to the list of project files), it works.

  let permanentUrl = Bundle.main.url(forResource: "INBOX24-2.2-resolv", withExtension: "conf") self.doc = UIDocumentInteractionController.init(url: permanentUrl!) //permanentUrl:file:///var/containers/Bundle/Application/40F14112-208E-4A97-8214-D55CC8E597C4/xxx.app/INBOX24-2.2-resolv.conf 

But when I go to the real code that stores the files in the application document directory, it does not work, the code looks like this:

 let url = URL.init(fileURLWithPath: storedPath self.doc = UIDocumentInteractionController.init(url: url) //url:file:///var/mobile/Containers/Data/Application/9624FFB3-8CB0-437C-A67B-C71AAB314370/Documents/INBOX24-2.2-resolv.conf 
+7
ios
source share
1 answer

I found the same problem on my iPhone, I just restarted my iPhone and was resolved.

0
source share

All Articles