Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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
Ios Swift TableView崩溃:“;缺少新可见行的单元格“;_Ios_Swift_Uitableview_Tableviewcell_Heightforrowatindexpath - Fatal编程技术网

Ios Swift TableView崩溃:“;缺少新可见行的单元格“;

Ios Swift TableView崩溃:“;缺少新可见行的单元格“;,ios,swift,uitableview,tableviewcell,heightforrowatindexpath,Ios,Swift,Uitableview,Tableviewcell,Heightforrowatindexpath,我在向tableview添加新行时遇到崩溃。简而言之,崩溃日志显示“新可见的第3行缺少单元格” 复制 1.向数据源添加N个对象量 2.手动添加相同的金额 单元格到tableview的数目 3.使用BeginUpdate-EndUpdate重新加载并设置动画 已知问题 此次坠机事件已在上讨论,并在上报告。他们对此问题的解决方案(不使用估计的单元格高度)对我不起作用,因为我需要两个不同的单元格高度 我的tableview由两个不同的单元格类组成。两者都有自己的标准高度,配置如下: func tabl

我在向tableview添加新行时遇到崩溃。简而言之,崩溃日志显示“新可见的第3行缺少单元格”

复制
1.向数据源添加N个对象量
2.手动添加相同的金额 单元格到tableview的数目
3.使用BeginUpdate-EndUpdate重新加载并设置动画

已知问题
此次坠机事件已在上讨论,并在上报告。他们对此问题的解决方案(不使用估计的单元格高度)对我不起作用,因为我需要两个不同的单元格高度

我的tableview由两个不同的单元格类组成。两者都有自己的标准高度,配置如下:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    if indexPath.row % (straightsetLogs.count + 1) == 0 {
        return 44
    } else {
        return tableView.rowHeight
    }
}

func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // (exerciseSets.count / straightsetLogs.count) = amount of (super)sets
    // (straightsetLogs.count + 1) = amount of cells needed for 1 (super)set
    return (exerciseSets.count / straightsetLogs.count) * (straightsetLogs.count + 1)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    // Headercell: 1 headercell for every (super)set
    if indexPath.row % (straightsetLogs.count + 1) == 0 {
        // Create header cells once for every set
        let headerCell = tableView.dequeueReusableCell(withIdentifier: CellID.setHeaderCell, for: indexPath) as! SetHeaderTableViewCell

        return configureHeaderCell(headerCell, forIndexPath: indexPath, totalCellsPerSet: straightsetLogs.count + 1)
    } else {
        // Create picker cells for rest of rows
        let pickerCell = tableView.dequeueReusableCell(withIdentifier: CellID.setPickerCell, for: indexPath) as! SetPickerTableViewCell

        // Configure according to set and movement
        return configurePickerCell(pickerCell, forIndexPath: indexPath, totalCellsPerSet: straightsetLogs.count + 1)
    }
}
在故事板中,我将tableview本身配置为行高260.0,对于标题单元格,我选中了“自定义行高”框并将其设置为44.0

当前状态
用于确定索引路径的正确单元格的代码起作用,可以通过删除indexPath代码处的行高度来解决崩溃问题。但我最终得到的所有细胞高度都是260.0

目标

我需要44.0高度的收割台单元格和260.0高度的选择器单元格,而不会发生此崩溃

在section和cellforrow方法中记下您的行数。您是否可以尝试使用return 260而不是return tableView.RowHeights。这不起作用。您指的是标题单元格和内容单元格,可能我遗漏了一些内容,但使用不同的部分来解决此问题,使用iOS标题不是更容易吗?顺便说一句,如果你在github上放一个小POC,肯定会更快地debug@MatteoCrippa对于构建tableview来说,这确实是一个更干净、更省钱的解决方案。我不知道可以创建自定义标题视图这一事实。我会重建它,看看崩溃是否仍然发生。