2016-02-25 75 views
0

我想在超级ViewController中提供AlertController。 (实际上,其中没有CollectionView),但AlertController呈现时。调试区域会出现一些错误:UICollectionViewFlowLayout错误,当AlertController呈现

//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. 

回答

0

我自己解决了。需要添加

alert.view.setNeedsLayout() 

然后前

self.presentViewController(alert, animated: true, completion: nil) 

,漏洞修复

0

我也有同样的问题,在我的屏幕上仅iphon6 Plus屏幕。请检查,如果你不及格的空衔,如果标题是空的,它传递零,如:中

UIAlertController *confirmAlert = [UIAlertController alertControllerWithTitle:nil message:displayMessage preferredStyle:UIAlertControllerStyleAlert]; 

代替

UIAlertController *confirmAlert = [UIAlertController alertControllerWithTitle:@"" message:displayMessage preferredStyle:UIAlertControllerStyleAlert]; 

它固定我的问题。祝你好运..