UIDocumentMenuViewController在iPad上崩溃,但在iPhone上没有



演示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)

2016-06-07 09:45:45.256记忆〔2994:977408〕未定义UICollectionViewFlowLayout,因为:2016-06-0709:45:45.260记忆[2994:977408]项目宽度必须小于UICollectionView的宽度减去左侧和右值,减去插入左值和右值的内容。2016-06-07 09:45:45.261记忆〔2994:977408〕相关UICollectionViewFlowLayout实例为&lt_UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>,它是附于;animations={bounds.origin=;bounds.size=;位置=;};层=;contentOffset:{0,0};contentSize:{0,0}>集合视图布局:&lt_UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>。2016-06-07 09:45:45.262记忆〔2994:977408〕做一个符号要捕获的UICollectionViewFlowLayoutBreakForInvalidSizes处的断点这在调试器中。

我不明白为什么错误消息引用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)

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

相关内容

最新更新