我有一个 tableView,其中自定义单元格由 NSMutableDictionaries 填充,位于 NSMutableArray 内。
现在,我想检查当前正在填充的单元格上方的单元格的 valueForKey@"Location"
。因为,如果该位置相同,下面的单元格应该留下一些标签 blanco。
例如:
[Thing on location: Building A has problem X]
[ and problem Y ]
[Thing on location: Building B has problem X]
(是的,我知道,一张 table 的“绘图”很差,哈哈)。
无论如何,在cellForRowAtIndexPath
中我已经尝试过代码:
if ((indexPath.row - 1) > -1)
{
NSString *eerste = [[NSString alloc] initWithFormat:@"%@", [[lijstErrors objectAtIndex:(indexPath.row - 1)] objectForKey:@"Location"]];
NSString *tweede = [[NSString alloc] initWithFormat:@"%@", [incInRow objectForKey:@"Location"]];
NSLog(@"Comparing %@ met %@", eerste, tweede);
}
问题是,它永远不会被调用。我的猜测是,每次填充单元格时都不会调用 cellForRowAtIndexPath
吗?有什么提示吗?
最佳答案
应该调用它,如果没有,可能是您忘记设置数据源。然后尝试
myTableView.dataSource =self;
尝试以下:
if ((indexPath.row - 1) >= -1)
关于ios - 具有双值的 TableView 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5787966/