Null 传递给需要 UIImageView 的非空参数的被调用者
Null passed to a callee that requires a non-null argument with UIImageView
升级到 Xcode7.2 后,我收到此警告:
Null passed to a callee that requires a non-null argument
我只知道如何通过使用@"" 而不是nil 来满足非空要求以避免对字符串发出此警告。 但是我不知道如何在 UIImageView 的情况下这样做,下面是我的代码:
if (imageFile)
{
UIImageView *imageLabel = [[UIImageView alloc] init];
[imageLabel setTag:CellImageLabelTag];
[cell.contentView addSubview:imageLabel];
} else {
UIImageView *imageLabel = [[UIImageView alloc] init];
[imageLabel setTag:CellImageLabelTag];
[cell.contentView addSubview:nil]; //warning here
}
请多多指教。提前致谢。
UIImageView *imageLabel = [[UIImageView alloc] init];
[imageLabel setTag:CellImageLabelTag];
[cell.contentView addSubview:imageLabel ]; //No warning here anymore :-)
您是否尝试将图像视图添加到单元格?如果是这样,您需要执行以下操作:
[cell.contentView addSubview:imageLabel];
编译器显示该警告是因为方法 addSubview
将 nonnull UIView *
作为参数。
升级到 Xcode7.2 后,我收到此警告:
Null passed to a callee that requires a non-null argument
我只知道如何通过使用@"" 而不是nil 来满足非空要求以避免对字符串发出此警告。 但是我不知道如何在 UIImageView 的情况下这样做,下面是我的代码:
if (imageFile)
{
UIImageView *imageLabel = [[UIImageView alloc] init];
[imageLabel setTag:CellImageLabelTag];
[cell.contentView addSubview:imageLabel];
} else {
UIImageView *imageLabel = [[UIImageView alloc] init];
[imageLabel setTag:CellImageLabelTag];
[cell.contentView addSubview:nil]; //warning here
}
请多多指教。提前致谢。
UIImageView *imageLabel = [[UIImageView alloc] init];
[imageLabel setTag:CellImageLabelTag];
[cell.contentView addSubview:imageLabel ]; //No warning here anymore :-)
您是否尝试将图像视图添加到单元格?如果是这样,您需要执行以下操作:
[cell.contentView addSubview:imageLabel];
编译器显示该警告是因为方法 addSubview
将 nonnull UIView *
作为参数。