iOS Plus屏幕 AlerController报错

来源:互联网 发布:92game仿影视大全源码 编辑:程序博客网 时间:2024/06/06 04:38

使用UIAlertController 在6P/6sP屏幕时报错


2016-06-02 10:03:27.023 app[1581:584039] the behavior of the UICollectionViewFlowLayout is not defined because:2016-06-02 10:03:27.023 app[1581:584039] 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-06-02 10:03:27.025 app[1581:584039] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x1603a9e80>, and it is attached to <UICollectionView: 0x15f30ce00; frame = (0 120.667; 270 44); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x1603aa940>; layer = <CALayer: 0x1603aa3b0>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x1603a9e80>.2016-06-02 10:03:27.025 app[1581:584039] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

UIAlertController代码如下:

    UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"账号验证" message:@"请输入138****1145的中间四位" preferredStyle:UIAlertControllerStyleAlert];        [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {        textField.placeholder = @"请输入138****1145的中间四位";        textField.textAlignment = NSTextAlignmentCenter;    }];        UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {            }];        UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {            }];        [alert addAction:cancelAction];    [alert addAction:sureAction];    [self presentViewController:alert animated:YES completion:nil];



解决的方法:在[self presentViewController:alert animated:YES completion:nil];之前增加一句代码:

    [alert.view setNeedsLayout];    [self presentViewController:alert animated:YES completion:nil];

解决问题的帮助网页链接:点击打开链接


0 0