我想在我的单元格中显示一个图像,但前提是JSON
数据的值为 1(只有 0 或 1 可能)也许如果JSON
数据的值为 0 显示不同的图像,所以每个单元格可以显示 2 个不同的图像.
到目前为止的问题是单元格包含图像,而不是JSON
数据的值是什么。
到目前为止的代码:
NSArray *arrayOfEntry = [allDataDictionary objectForKey:@"notities"];
for (NSDictionary *diction in arrayOfEntry)
{
sonResults = [allDataDictionary objectForKey:@"notities"];
NSMutableString *checkvink = [diction objectForKey:@"not_verwerkt"];
if(![checkvink isEqual: @"1"])
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"vink" ofType:@"png"];
imageData = [NSData dataWithData:[NSData dataWithContentsOfFile:path]];
}
}
然后我显示这样的图像
UIImage *imageLoad = [[UIImage alloc] initWithData:imageData];
cell.notAfbeel.image = imageLoad;
我究竟做错了什么?
编辑:完成 cellForRowAtIndexPath
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *Cellidentifier = @"Cell";
NotitieCell *cell = [tableView dequeueReusableCellWithIdentifier:Cellidentifier];
if(!cell)
{
cell = [[NotitieCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cellidentifier];
}
NSDictionary *appsdict = [jsonResults objectAtIndex:indexPath.row];
UIImage *imageLoad = [[UIImage alloc] initWithData:imageData];
cell.notAfbeel.image = imageLoad;
return cell;
}
JSON数据
{
"notities": [{
"not_nr": "1191555",
"not_tijd": "12:29:54",
"not_type": "0",
"not_behandeld": "Richard",
"not_bestemd": "Richard",
"not_contactpers": "Maarten",
"not_prioriteit": "1",
"not_onderwerp": "Printer staat er nog steeds in",
"not_naam": "apple store",
"not_woonpl": "Amsterdam",
"not_land": "NL",
"not_verwerkt": "0"
}
}