呈现一个 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 Memorise[2994:977408] the behavior of the UICollectionViewFlowLayout is not defined because: 2016-06-07 09:45:45.260 Memorise[2994:977408] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. 2016-06-07 09:45:45.261 Memorise[2994:977408] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x1668e6e0>, and it is attached to ; animations = { bounds.origin=; bounds.size=; position=; }; layer = ; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x1668e6e0>. 2016-06-07 09:45:45.262 Memorise[2994:977408] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
我不明白为什么错误消息引用 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/