UIDocumentMenuViewController

UIDocumentMenuViewController

提供一个UIDocumentMenuViewController以便能够将文件加载到应用中。在iPhone上可以使用,但在iPad上则不能。使用iOS9。知道有什么问题吗?

dmvc = UIDocumentMenuViewController(documentTypes: ["public.data"], inMode: .Import)
dmvc!.delegate = self
dmvc!.popoverPresentationController?.sourceView = addSongButton
self.presentViewController(dmvc!, animated: true, completion: nil)



我不明白为什么错误消息会引用collectionView?我根本不使用collectionView。也许UIDocumentMenuViewController将其作为内部组件?

最佳答案

iPad有一些关于ActionSheets及其取消按钮的特殊规则,通常取决于您从何处显示ActionSheets,因此这是解决崩溃问题的方法:

     let importMenu = UIDocumentMenuViewController(documentTypes: [kUTTypeHTML as String ], in: .import)
    importMenu.delegate = self
    importMenu.modalPresentationStyle = .popover
    importMenu.popoverPresentationController?.sourceView = self.view
    self.present(importMenu, animated: true, completion: nil)

关于ios - UIDocumentMenuViewController在iPad上崩溃,但在iPhone上不崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37673528/

10-13 04:29