Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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 DidDecreawatindexpath不是';我没打电话_Ios_Uitableview_Nsindexpath_Multipleselection - Fatal编程技术网

Ios DidDecreawatindexpath不是';我没打电话

Ios DidDecreawatindexpath不是';我没打电话,ios,uitableview,nsindexpath,multipleselection,Ios,Uitableview,Nsindexpath,Multipleselection,我已经在一个包含多个选择的UITableView中实现了didderowatindexpath方法 由于某些原因,diddescrowatindexpath未被委托调用。有什么建议吗?(我没有意外拼错didselectrowatinexpath) 谢谢 如果我没有弄错的话,UITableView没有用于取消选择单元格的内置方法。我相信您需要调用取消行索引路径:才能调用取消行索引路径。有关单元格选择的一些注意事项: 如果用户单击的单元格与已选择的单元格不同,则仅在单个选择中调用DIDDesele

我已经在一个包含多个选择的
UITableView
中实现了
didderowatindexpath
方法

由于某些原因,
diddescrowatindexpath
未被委托调用。有什么建议吗?(我没有意外拼错
didselectrowatinexpath


谢谢

如果我没有弄错的话,
UITableView
没有用于取消选择单元格的内置方法。我相信您需要调用
取消行索引路径:
才能调用
取消行索引路径。

有关单元格选择的一些注意事项:

  • 如果用户单击的单元格与已选择的单元格不同,则仅在单个选择中调用
    DIDDeselevationIndexPath
  • 调用
    didSelectRowAtIndexPath
    选择新行,调用
    didSelectRowAtIndexPath
    取消选择上一行
  • 在具有多个选择的
    UITableView
    中,不会取消选择上一行,因此您的取消选择将在
    didSelectRowAtIndexPath
您可以使用已实现的委托方法获取单元格,并在检查其选择后对其进行修改,如下所示:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    if (cell.selected) {
        // ... Uncheck
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }
}

我目前使用的是一个具有多重选择的tableView,DidDeceloseRowatineXpath方法正在为我调用(不同于上面答案中第三个项目符号所述)

我确实注意到,“预选”的单元格没有正确调用DidDeceloseRowatineXpath,除非我做了三件事:

  • 在cellForRowAtIndexPath中,当我找到要预选的单元格时(您可以检查匹配的数组条目或字符串,就像我所做的那样),为该单元格设置cell.selected=true
  • 在CellForRowatineXpath中,也调用方法 选择要预选的单元格的行索引路径
  • 在Interface Builder中,取消选中tableView的“触摸显示选择”复选标记。奇怪的是,这是为了确保在点击预选项(即应取消选择)时,正确调用了DidDeceloseRowatingIndexPath。
  • 示例代码:

    if productsReceived!.rangeOfString(cell.productName.text!) != nil {
        cell.accessoryType = .Checkmark 
        tableView.selectRowAtIndexPath(indexPath, animated: true,   scrollPosition: UITableViewScrollPosition.None)
        cell.selected = true
    }
    

    我希望这能帮助那些试图用预选单元格实现多重选择的人

    是否已将UITableView委托设置为指向包含didSelectRowAtIndexPath的对象?类似于
    tableView.delegate=self