我正在向 URL 发出请求以下载图像。我将它作为NSData
对象接收,但是当我尝试将其转换UIimage with imageWithData:
为UIImage
未加载时。这是我的代码
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
__weak typeof(request)weakRequest = request;
__block UIImage * imager;
__block NSData * image;
[request setCompletionBlock:^{
[self parseXMLFileAtFileId:[weakRequest responseData]];
if (!files){
cell.correctImage.image = [UIImage imageNamed:@"sidebarPlaceholder"];
}
else{
NSURL *url = [NSURL URLWithString:[self downloading:[files objectAtIndex:0]]];
__block ASIHTTPRequest *requester = [ASIHTTPRequest requestWithURL:url];
__weak typeof(request)weakRequesting = requester;
[requester setCompletionBlock:^{
image = [weakRequesting responseData];
imager = [UIImage imageWithData:image];
cell.correctImage.image = imager;
[cell layoutIfNeeded];
}];
[requester startAsynchronous];
}
}];
以前我通过明确UIImageView
说明UITableviewCell
. 如何让图像显示?