所以我写了这个代码,在我想要选择的行旁边添加一个复选标记,因为我想要多个选定的行
UITableViewCell *cell = [tableView cellForRowAtIndexPath:path]; if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; } else { cell.accessoryType = UITableViewCellAccessoryCheckmark; }
NSArray *selectedIndexPaths = [self.LightsView indexPathsForSelectedRows];
解决方法
要使indexPathsForSelectedRows:方法正常工作,必须配置表视图以允许多个单元格选择:
tableView.allowsMultipleSelection = YES;