Iphone 在2个部分的1行中添加复选标记

Iphone 在2个部分的1行中添加复选标记,iphone,xcode,uitableview,checkmark,Iphone,Xcode,Uitableview,Checkmark,如果我使用这段代码,我可以只在1行中添加1个复选标记,但在2个部分中添加1个复选标记,但我需要在每个部分中添加1个复选标记 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int newRow = [indexPath row]; int oldRow = (lastIndexPath != nil) ? [lastIndexPath r

如果我使用这段代码,我可以只在1行中添加1个复选标记,但在2个部分中添加1个复选标记,但我需要在每个部分中添加1个复选标记

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

    int newRow = [indexPath row];
    int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; 

    if(newRow != oldRow)
    {
        UITableViewCell* newCell = [tableView cellForRowAtIndexPath:indexPath];
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;

         UITableViewCell* oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
        oldCell.accessoryType = UITableViewCellAccessoryNone;
        lastIndexPath = indexPath;
    }
    [tableView deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:YES];
}
如果我用这个

if (indexPath.section == 0);
对于每个部分,它都不起作用


感谢阅读

为什么不使用选择器视图?我考虑picker view,但对于我的应用程序,最好使用checkmark thx