到目前为止搜索堆栈溢出我还没有发现像我的情况。任何帮助都非常感谢:我一直看到,如果我在A人身上勾上勾号,H人也会有一个人,并且约有10人离开。基本上每10个重复一个复选标记。带复选标记的UITableViewCell,复制复选标记
这里是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{static NSString *CellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text =
[NSString stringWithFormat:@"%@ %@", [[myArrayOfAddressBooks objectAtIndex:indexPath.row] objectForKey:@"FirstName"],[[myArrayOfAddressBooks objectAtIndex:indexPath.row] objectForKey:@"LastName"]];
cell.detailTextLabel.text =
[NSString stringWithFormat:@"%@", [[myArrayOfAddressBooks objectAtIndex:indexPath.row] objectForKey:@"Address"]];
return cell;
}
在我做了选择行的索引路径我有这样的:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
cell = [self.tableView cellForRowAtIndexPath: indexPath];
if ([[myArrayOfAddressBooks objectAtIndex:indexPath.row] objectForKey:@"emailSelected"] != @"YES")
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[[myArrayOfAddressBooks objectAtIndex:indexPath.row] setValue:@"YES" forKey:@"emailSelected"];
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
[[myArrayOfAddressBooks objectAtIndex:indexPath.row] setValue:@"NO" forKey:@"emailSelected"];
}