UIDocumentMenuViewController Auto Layout error

Originator:matej
Number:rdar://27471372 Date Originated:21-Jul-2016 05:09 PM
Status:Open Resolved:
Product:iOS Product Version:9.3
Classification:UI/Usability Reproducible:Always
 
Summary:

UIDocumentMenuViewController is showing an Auto Layout error during initialization. 

Steps to Reproduce:

Set up an app with the correct iCloud entitlements. Use the following code to initialize a UIDocumentMenuViewController:

UIDocumentMenuViewController *pickerMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:types inMode:UIDocumentPickerModeImport];

Expected Results:

No Auto Layout errors.

Actual Results:

The following error is printed in the console:

2016-07-21 16:49:56.944 Viewer[3297:1470956] the behavior of the UICollectionViewFlowLayout is not defined because:
2016-07-21 16:49:56.944 Viewer[3297:1470956] 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-07-21 16:49:56.946 Viewer[3297:1470956] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x157b23430>, and it is attached to <UICollectionView: 0x1568f7a00; frame = (0 44; 10 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x157b23ff0>; animations = { bounds.origin=<CASpringAnimation: 0x155f153a0>; bounds.size=<CASpringAnimation: 0x155f03ef0>; position=<CASpringAnimation: 0x155f1fe90>; }; layer = <CALayer: 0x157b23a60>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x157b23430>.
2016-07-21 16:49:56.946 Viewer[3297:1470956] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

Here is the backtrace from the menu initialization onwards:

#0	0x0000000189246ec0 in UICollectionViewFlowLayoutBreakForInvalidSizes ()
#1	0x0000000189248180 in -[_UIFlowLayoutSection logInvalidSizesForHorizontalDirection:warnAboutDelegateValues:] ()
#2	0x0000000188b23074 in -[_UIFlowLayoutSection computeLayout] ()
#3	0x0000000189208af4 in __56-[UICollectionViewFlowLayout _updateItemsLayoutForRect:]_block_invoke ()
#4	0x000000018373b944 in __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke ()
#5	0x000000018373b7b4 in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
#6	0x000000018920890c in -[UICollectionViewFlowLayout _updateItemsLayoutForRect:] ()
#7	0x0000000189208c78 in -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] ()
#8	0x0000000188a06e18 in -[UICollectionViewFlowLayout collectionViewContentSize] ()
#9	0x0000000188a01744 in -[UICollectionViewData _validateContentSize] ()
#10	0x0000000188a00bfc in -[UICollectionViewData validateLayoutInRect:] ()
#11	0x0000000188a007d0 in -[UICollectionView layoutSubviews] ()
#12	0x000000018899c1e4 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#13	0x000000018632e994 in -[CALayer layoutSublayers] ()
#14	0x00000001863295d0 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#15	0x00000001889b30a4 in -[UIView(Hierarchy) layoutBelowIfNeeded] ()
#16	0x0000000189285a74 in __45-[_UIAnimationCoordinator animateTransition:]_block_invoke ()
#17	0x00000001889d8fa8 in +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] ()
#18	0x0000000188c2f250 in +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:] ()
#19	0x0000000189285a00 in -[_UIAnimationCoordinator animateTransition:] ()
#20	0x0000000189285368 in -[_UIAnimationCoordinator animate] ()
#21	0x0000000188e1912c in -[UIAlertController _contentViewControllerWillTransitionToSize:withAnimations:] ()
#22	0x0000000189308b00 in -[_UIAlertControllerView _sizeOfContentViewControllerChanged] ()
#23	0x0000000188e15bc4 in -[UIAlertController viewDidLoad] ()
#24	0x00000001889a0c40 in -[UIViewController loadViewIfRequired] ()
#25	0x00000001889a0844 in -[UIViewController view] ()
#26	0x0000000188f6a880 in -[UIDocumentMenuViewController _setChildViewController:] ()
#27	0x0000000188f6a178 in -[UIDocumentMenuViewController _commonInitWithCompletion:] ()
#28	0x0000000188f697b0 in -[UIDocumentMenuViewController initWithDocumentTypes:inMode:] ()

Regression:

Tested on iPad Air 2, iOS 9.2. 

Notes:

Related mentions of the porblem found online:
 - https://forums.developer.apple.com/message/125180#125180
 - http://stackoverflow.com/questions/35457136/auto-layout-error-using-uidocumentmenuviewcontroller
 - perhaps rdar://24858445

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!