UIDocumentMenuViewController crashes on iPad, but not on iPhone

The UIDocumentMenuViewController for loading a file into the application. On the iPhone, this works, but not on the iPad. Using iOS9. Any idea what's wrong?

 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 Remember [2994: 977408] the behavior of the UICollectionViewFlowLayout is not defined because: 2016-06-07 09: 45: 45.260 Remember [2994: 977408] the element width must be less than the width of the UICollectionView for minus insertion sections and right values, minus inserting contents left and right. 2016-06-07 09: 45: 45.261 Memorize [2994: 977408] Relevant Instance of UICollectionViewFlowLayout <_UIAlertControllerCollectionViewFlowLayout: 0x1668e6e0>, and this 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 Remember [2994: 977408] Make a symbolic breakpoint in UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

What I do not understand, why the error message refers to collectionView ? I do not use collectionView at all. Maybe the UIDocumentMenuViewController has it as an internal component?

+3
ios ios9 uicollectionview
source share
2 answers

IPad has special rules about ActionSheets and their cancel buttons. This usually depends on where you show the ActionSheets, so you can solve the crash problem:

  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) 
+3
source share

I had the same problem. I set sourceView = self.view and had to create sourceRect = theButton.frame.

0
source share

All Articles