Maison  >  Questions et réponses  >  le corps du texte

ios - 在UIAlertController中添加UITextField控制台报错

我实现了如图所示的警示框。(警示框中包含输入框)

实现代码如下

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"test" message:@"test" preferredStyle:UIAlertControllerStyleAlert];
            [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
                textField.placeholder = @"test";
                textField.adjustsFontSizeToFitWidth = YES;
            }];
            UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                NSLog(@"test");
            }];
            [alertController addAction:cancleAction];
            [self presentViewController:alertController animated:YES completion:nil];

但是在运行时每当点击弹出警示框的时候,控制台都会报这样的错误:

the behavior of the UICollectionViewFlowLayout is not defined because:
2016-01-04 22:39:43.136 temp[1819:71277] 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-01-04 22:39:43.137 temp[1819:71277] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x7fb81d169b70>, and it is attached to <UICollectionView: 0x7fb81c10d800; frame = (0 120.667; 270 44); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7fb81d18d800>; layer = <CALayer: 0x7fb81ae37510>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x7fb81d169b70>.
2016-01-04 22:39:43.137 temp[1819:71277] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

这是为什么呢?

巴扎黑巴扎黑2764 Il y a quelques jours648

répondre à tous(3)je répondrai

  • 迷茫

    迷茫2017-04-17 17:22:16

    在stack overflow上面找到答案了,这是当模拟器选择iPhone6plus 和 iPhone6splus的时候console才会出现这个提示,选择其他模拟器的时候不会出现这个问题,这是apple的一个bug

    répondre
    0
  • 怪我咯

    怪我咯2017-04-17 17:22:16

    他叫你打个断点看看,试了吗

    répondre
    0
  • 黄舟

    黄舟2017-04-17 17:22:16

    你的UICollectionViewFlowLayout子类folw的高度是不是比UICollectionView的高度高了?

    répondre
    0
  • Annulerrépondre