Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode UITableView-基于索引路径设置单元格内容_Xcode_Uitableview - Fatal编程技术网

Xcode UITableView-基于索引路径设置单元格内容

Xcode UITableView-基于索引路径设置单元格内容,xcode,uitableview,Xcode,Uitableview,除了强迫用户完全重新启动应用程序以将不同的数据转储到表中之外,我不知道如何修复这个bug 如果我折叠每个部分(即清空expandedSectionsset并重新加载,只留下可见的伪标题),问题就不那么严重了,但它不会消失 编辑: 初始载荷: 重新加载后: 链接而不是图像,因为它是iPad应用程序。 使用一些虚拟内容进行测试 这有什么帮助吗?我知道需要更多的代码来提供真正的帮助,但我不知道还要添加什么,缺少指向整个视图代码的链接。它可能与单元格缓存有关…关于将图像设置为行==0,否则不清除它…但

除了强迫用户完全重新启动应用程序以将不同的数据转储到表中之外,我不知道如何修复这个bug

如果我折叠每个部分(即清空
expandedSections
set并重新加载,只留下可见的伪标题),问题就不那么严重了,但它不会消失


编辑:

初始载荷:
重新加载后:
链接而不是图像,因为它是iPad应用程序。
使用一些虚拟内容进行测试


这有什么帮助吗?我知道需要更多的代码来提供真正的帮助,但我不知道还要添加什么,缺少指向整个视图代码的链接。

它可能与单元格缓存有关…关于将图像设置为行==0,否则不清除它…但是由于显示的代码数量有限,很难更具体。

您是否尝试过为第一个单元格和另一个单元格设置不同的单元格标识符剩下的一个?
tableView在创建新单元时重用相同的单元类型,因此可能会使它们混淆。通过为每种类型使用不同的单元格标识符,它将准确地知道何时使用每个单元格。

因此,滥用数据源“更容易、更简单”,而不是使用自定义标题视图?听起来好像是因为您有问题。分区中不能有0行。我希望能够在某些部分中显示标题,但不显示行,并允许用户动态选择展开/折叠的行。这是一个必要的实现,比我能想到的任何替代方案都好看。你在说什么“滥用”,你的实现会是什么样子?你有没有试过为第一个单元设置一个不同的单元标识符,为其余的单元设置另一个?我来试试,Andrei。
cell.backgroundView=nil对正确加载的单元格无害。对于那些获得标题背景的人(即使
indexPath.row
大于0),唯一的区别是它不是一个图像,而是一个白色块。文本看起来有误,标题附件仍然存在。不能解决任何问题。这证明了这是一个缓存问题。也就是说,当您为==0的情况配置内容时,您并没有将它们清除或替换为>0。(从你的问题中,我猜不出有更多的东西,而不仅仅是图像。)
- (UITableViewCell *)tableView:... cellForRowAtIndexPath:... {
    // init and sanity check

    if (indexPath.row == 0) {
        // make cell look like a section header
        // easier and less complex than using a custom header view

        NSLog(@"header");
        // should prove that only four cells get the bg image
        // and yet, almost every time the table is reloaded
        // one more cell unexpectedly gets the background
        // without putting another line in the debugger
    } else {
        // normal cells after row 0
        // BUG: some of these are getting the row 0 background

        NSLog(@"row");
        // firing exactly the right number of times --
        // once for each row with an index greater than 0
        // so why are some of these cells getting the header bg?

        // when these cells get the headers' contents
        // they behave exactly as one would expect
        // except that they should be the normal rows
    }

    // misc stuff, not causing problems

    return cell;
}