UIDocumentMenuViewController在iPad上崩溃,但在iPhone上不崩溃

Ján*_*nos 4 ios uicollectionview uidocumentmenuvc ios9

呈现一个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)
Run Code Online (Sandbox Code Playgroud)

2016-06-07 09:45:45.256 Memorise [2994:977408]未定义UICollectionViewFlowLayout的行为,因为:2016-06-07 09:45:45.260 Memorise [2994:977408]项目宽度必须小于UICollectionView的宽度减去该部分插入的左右值,减去内容插入的左右值。2016-06-07 09:45:45.261备忘录[2994:977408]相关的UICollectionViewFlowLayout实例为<_UIAlertControllerCollectionViewViewLayout:0x1668e6e0>,并将其附加到; 动画= {bounds.origin =; bounds.size =; position =; }; 层=; contentOffset:{0,0}; contentSize:{0,0}>集合视图布局:<_UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>。2016-06-07 09:45:45.262记忆[2994:

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

Sat*_*ync 5

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)
Run Code Online (Sandbox Code Playgroud)


MSc*_*ler 0

我有同样的问题。我设置了sourceView = self.view,并且必须制作一个sourceRect = theButton.frame。