【发布时间】:2014-09-07 22:58:24
【问题描述】:
我得到 JSON 的图像。像这样:-
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSMutableArray *al=[NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
for (NSDictionary *diction in al)
{
NSString *geting =[diction valueForKey:@"dealimage"];
NSLog(@"dealimage is %@",geting);
NSData *getdata=[[NSData alloc]initWithData:[NSData dataFromBase64String:geting]];
NSLog(@"good day %@",getdata);
dataimages=[UIImage imageWithData:getdata];
NSLog(@"dataimages %@",dataimages);
[imagesarray addObject:dataimages];
}
NSLog(@"images array is array%@",imagesarray);
NSLog(@"dataimages 8images %@",dataimages);
}
当我打印图像数组时,它显示如下:-
images array is array(
"<UIImage: 0x7539b70>",
"<UIImage: 0x7176e00>",
"<UIImage: 0x7182960>",
"<UIImage: 0x7185d40>",
"<UIImage: 0x7541d00>",
"<UIImage: 0x7186e30>",
"<UIImage: 0x7186ff0>",
"<UIImage: 0x7187410>"
)
我尝试的是 NSString 通过 Base64String 传递给 NSData,然后 NSData 传递给 UIImage,然后 UIImage 传递给 NSMutablearray(imagearray)。现在我将此数组传递给 UITableViewCell 比如:-
cell.imageView.image = [imagesarray objectAtIndex:indexPath.row];
但是图像没有显示在 UITableViewCell 所以请给我关于我的问题的任何想法。 感谢高级
【问题讨论】:
-
解析完数据后是否重新加载tableView?
-
@Morpheus 开玩笑说我尝试在 UITableViewCell 上显示 Json 图像
-
如果您在实际解析数据之前已经创建了tableview数据源,那么您必须在得到响应后重新加载数据才能在tableView中显示它
-
只有一行
[yourtableview reloadData];在完成你的 for 循环之后。 -
AFNetworking 将为您提供更多帮助。只需正常调用您的变量即可。以图像数组为例。
标签: ios objective-c uitableview uiimage nsmutablearray