我想在 super ViewController 中呈现一个 AlertController。 (事实上,里面没有CollectionView),但是当AlertController出现时。调试区会调用一些bug:
//2016-02-25 14:55:06.721 treatα[53173:1063624] the behavior of the
UICollectionViewFlowLayout is not defined because:
//2016-02-25 14:55:06.721 treatα[53173:1063624] the item height must
be less than the height of the UICollectionView minus the section
insets top and bottom values, minus the content insets top and
bottom values.
//2016-02-25 14:55:06.722 treatα[53173:1063624] The relevant UICollectionViewFlowLayout instance is
<_UIAlertControllerCollectionViewFlowLayout: 0x7fc883dfb1d0>, and it is attached to <UICollectionView: 0x7fc8848de800;
frame = (0 104.667; 270 44); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7fc883dfbb50>; layer = <CALayer: 0x7fc883dfb680>; contentOffset: {0, 0};
contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x7fc883dfb1d0>.
//2016-02-25 14:55:06.722 treatα[53173:1063624] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes
to catch this in the debugger.
最佳答案
我自己解决了。需要添加
alert.view.setNeedsLayout()
之前
self.presentViewController(alert, animated: true, completion: nil)
然后,修复bug
关于ios - 当 AlertController 出现时,UICollectionViewFlowLayout 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35620576/