Ios 无法识别的SDWebImage选择器
我在单元格中显示图像时发生以下崩溃。 UIImageView sd_setImageWithURL:Placeholder图像:已完成:::无法识别的选择器已发送到实例0x7fbce1521e70“ 我按照提供的所有指令进行操作,但仍然无法获得任何信息,我将另一个链接器标志Ios 无法识别的SDWebImage选择器,ios,objective-c,sdwebimage,Ios,Objective C,Sdwebimage,我在单元格中显示图像时发生以下崩溃。 UIImageView sd_setImageWithURL:Placeholder图像:已完成:::无法识别的选择器已发送到实例0x7fbce1521e70“ 我按照提供的所有指令进行操作,但仍然无法获得任何信息,我将另一个链接器标志设置为-Objc`但仍然得到相同的错误 我的代码: 您可以检查获得的视图类型以避免崩溃 UIImageView *img = (UIImageView *)[cell.contentView viewWithTag:1];
设置为
-Objc`但仍然得到相同的错误
我的代码:
您可以检查获得的视图类型以避免崩溃
UIImageView *img = (UIImageView *)[cell.contentView viewWithTag:1];
if ([img isKindOfClass:[UIImageView class]]) { //it will true if img is kind of UIImageView
[img sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@thumb_%@",kImageUrl,[dict objectForKey:@"student_photo"]]]
placeholderImage:[UIImage imageNamed:@"not_found.png"]];
} else {
NSLog(@"It is not an image view.")
}
您需要在`单元格'中将图像视图设置为'tag=1',否则您的图像将永远无法填充图像。基于您的崩溃日志和下面的代码
UIImageView *img = (UIImageView *)[cell.contentView viewWithTag:1];
变量img
可能是nil或其他视图。请仔细检查imageView的标记
如果一切正常,请检查您的单元格xib(IBOutlet连接中不应有任何错误或警告),如果您使用xib创建了自定义单元格。请尝试将“其他链接器标志”设置为“-ObjC”,而不是“\u ObjC”
这对我很有用。分享你的代码。你能附加一些代码吗?@satish我添加了检查你的SDWebImagePod版本你确定吗
[cell.contentView viewWithTag:1]
真的是一个UIImageView
?在自定义单元格中我需要设置标记?是的,在单元格中你需要设置像cell.yourImageView.tag=1;
我只设置为-Objc
UIImageView *img = (UIImageView *)[cell.contentView viewWithTag:1];