问题描述
呈现一个UIDocumentMenuViewController
以便能够将文件加载到应用程序中.在iPhone上可以使用,但在iPad上不能使用.使用iOS9.知道有什么问题吗?
Presenting a UIDocumentMenuViewController
to be able to load file into app. On iPhone it works, but not on iPad. Using iOS9. Any idea what is wrong?
dmvc = UIDocumentMenuViewController(documentTypes: ["public.data"], inMode: .Import)
dmvc!.delegate = self
dmvc!.popoverPresentationController?.sourceView = addSongButton
self.presentViewController(dmvc!, animated: true, completion: nil)
我不明白为什么错误消息引用了collectionView
?我根本不使用collectionView.也许UIDocumentMenuViewController
有它作为内部组件吗?
What I do not understand why error message refers collectionView
? I do not use collectionView at all. Maybe UIDocumentMenuViewController
has it as inner component?
推荐答案
iPad有一些有关ActionSheets及其取消按钮的特殊规则,通常取决于显示ActionSheets的位置,因此这是解决崩溃的方法问题:
iPad has some special rules about ActionSheets and their cancel buttons, It usually depends on where you are displaying the ActionSheets from, so this is how you can resolve the crashing issue:
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)
这篇关于UIDocumentMenuViewController在iPad上崩溃,但在iPhone上不崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!