我想在我的單元格中顯示圖像,但前提是JSON
數據的值爲1(只有0或1可能) 也許如果JSON
數據的值爲0顯示不同的圖像,所以每個細胞可以顯示2個不同的圖像。
到目前爲止的問題是,單元格包含圖像,而不是數據的值是什麼JSON
數據是。if語句在單元格中顯示圖像
到目前爲止的代碼:
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"
}
}
發表您的整個的cellForRowAtIndexPath方法 –
發佈的cellForRowAtIndexPath – SpeedfreakR
只是語句之前分配的imageData中的cellForRowAtIndexPath本身 「的UIImage * imageLoad = [[UIImage的頁頭] initWithData:爲imageData]。」 對不起延遲夥計 –