Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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
Select 点击一行将选择多行_Select_Ios5_Tableview_Rows - Fatal编程技术网

Select 点击一行将选择多行

Select 点击一行将选择多行,select,ios5,tableview,rows,Select,Ios5,Tableview,Rows,我的桌面视图中有一个奇怪的问题。我想选择行,只想显示复选标记。我有一个包含多个部分的tableview。选择行并显示复选标记很好,但是在tableview下10行,该行也将被选中???当选择多行时,同样向下10行,将显示多个选择 我正在使用: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { [tableView deselectRowAtInd

我的桌面视图中有一个奇怪的问题。我想选择行,只想显示复选标记。我有一个包含多个部分的tableview。选择行并显示复选标记很好,但是在tableview下10行,该行也将被选中???当选择多行时,同样向下10行,将显示多个选择

我正在使用:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath {
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:newIndexPath];
    if (cell.accessoryType == UITableViewCellAccessoryNone) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;

        // Reflect selection in data model
    } else if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
        cell.accessoryType = UITableViewCellAccessoryNone;
        // Reflect deselection in data model
    }
}

这不是选择另一行,而是重复使用同一个复选标记的单元格。在tableView:DidSelectRowatineXpath中:您正在使用单元格存储状态。在tableView:cellForRowAtIndexPath中:您没有处理行是否应该有复选标记

您可能需要做的是在didSelectRow中设置一个ivar NSMutableSet。。根据检查状态,从集合中添加或删除indexPath。然后在cellForRow。。根据indexPath在集合中的成员身份设置accessoryType属性

编辑抱歉,我没有捕捉到在数据模型中将状态保存到的注释。在这种情况下,您只需添加签入cellForRow。。。。由于这是一个常见的问题,我将保留原始答案