SDWebImage|SDWebImage 下载 中文或者空格 图片路径

前言: 【SDWebImage|SDWebImage 下载 中文或者空格 图片路径】最近做项目啥时候遇到一个后台返回带有中文字符的图片路径,如果不做处理,SDWebImage就无法加载,图片路径如:
http://119.145.140.214:8080//images/studio/1f1c0158f0b526d50000/1482214740697主图哈哈.jpg
中文路径解决方法:

NSString *orginImageUrl = model.portrait1; NSString * imageUrl = [orginImageUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [_iconImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"icon_ordinary"]];

空格图片路径解决方法:
NSString *orginImageUrl = model.portrait1; NSString *imageUrl = [orginImageUrl stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; [_iconImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"icon_ordinary"]];

    推荐阅读