ios - 当 AlertController 出现时,UICollectionViewFlowLayout 错误

标签 ios objective-c swift

我想在 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/

相关文章:

ios - 根据与设备的距离检测信标

objective-c - UIViews 太多会导致延迟

arrays - Swift 通用数组 Equatable 类型转换

html - 将 Webview 窗口添加到加载本地存储的 HTML 的现有 iOS 应用程序

ios - 从字典数组中删除

ios - 如何在IOS 6/7上设置导航栏颜色

ios - Right Detail UITableViewCell 在 iPad 上不显示完整行

iphone - stringFromDate 总是 NIL

ios - Swift 中的 4 x 2 按钮键盘

快速解析查询跳过空列