Это моя функция
@discardableResult func openFile(_ url: URL, in view: UIView) -> Bool {
guard url.isFileURL, FileManager.default.fileExists(atPath: url.path) else {
fatalError()
}
let tempURL = URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!.appendingPathComponent(url.lastPathComponent))
if !FileManager.default.fileExists(atPath: tempURL.path) {
do {
try FileManager.default.copyItem(at: url, to: tempURL)
} catch let error {
log.error(error)
}
}
log.debug("cache url \(tempURL)")
document = UIDocumentInteractionController(url: tempURL)
document?.delegate = self
log.debug(view)
log.debug(document?.uti)
log.debug(document?.name)
return document!.presentOptionsMenu(from: view.frame, in: view, animated: true)
}
Когда оно выполнено, мое приложение не может представить меню, хотя оно возвращает true и делегат вызовет documentInteractionControllerWillPresentOptionsMenu
Журнал:
14:50:02.778 ? DEBUG Earth.openFile():237 - cache url file:///var/mobile/Containers/Data/Application/BF11E458-4208-4CD4-9329-8B65C2B4AF6F/Library/Caches/0.doc
14:50:02.780 ? DEBUG Earth.openFile():240 - <UIWindow: 0x10697f4c0; frame = (0 0; 414 736); autoresize = W+H; gestureRecognizers = <NSArray: 0x28179e5e0>; layer = <UIWindowLayer: 0x281333800>>
14:50:02.798 ? DEBUG Earth.openFile():241 - Optional("com.microsoft.word.doc")
14:50:02.799 ? DEBUG Earth.openFile():242 - Optional("0.doc")
14:50:02.823 ? DEBUG Earth.documentInteractionControllerWillPresentOptionsMenu():265 - willPresentOptionsMenu