ios - 具有双值的 TableView 单元格

标签 ios objective-c xcode uitableview cell

我有一个 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/

相关文章:

ios - 为 iOS 发布订阅?

ios - 文件是为 arm64 构建的,它不是链接的体系结构 (x86_64)

ios - 图像比例 AF 网络

iphone - 立方根-DDMathParser-还是一般而言?

ios - XCode 上传数据文件到 iPad "Permission Denied"?

ios - iOS 用户界面元素的名称

android - Xamarin——支持 9 补丁?

ios - 按地址和地名自动完成搜索栏 - Swift 4

objective-c - Imageview 的 "touch area rect"在动画移动到其他地方后仍然保留

ios - 如何检查此过程是否已完成?