headimageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, DEVW, DEVW/2)];
headimageView.contentMode = UIViewContentModeScaleAspectFit;
NSString *strImg = [strJson objectForKey:@"image"];
if (strImg.length > 0) {
strImg = [FuncPublic GetImageUrl:strImg];
strImg = [strImg stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:strImg];
[headimageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"jz3.png"]];
} else {
headimageView.image = nil;
}
+(NSString*)GetImageUrl:(NSString*)_path
{
NSRange range = [_path rangeOfString:@"http://"];//判断字符串是否包含
if (range.length >0)//包含
{
return _path;
}
else//不包含
{
return [NSString stringWithFormat:@"%@%@",kAPIHost,_path];
}
}
- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
[self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
}