一、思路

  先设置一个chooseCelltag标记(类型为NSIndexPath),然后在点击cell触发的时候,如果tag设置有值,就设置

     

 UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:tag];

          selectedCell.accessoryType = UITableViewCellAccessoryNone;

 

  然后把tag = indexPath

  然后

  

cell.accessoryType = UITableViewCellAccessoryCheckmark;

 

二、主要代码:

1、在.m的interface中

@interface ChooseTypeViewController ()

{

    NSIndexPath *tag; 

}

@end

 

2、在点击cell触发的事件中。

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

{

    [tableView deselectRowAtIndexPath:indexPath animated:TRUE];

    UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];

    if (tag) {

        UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:tag];

        selectedCell.accessoryType = UITableViewCellAccessoryNone;

    }

    tag = indexPath;

    cell.accessoryType = UITableViewCellAccessoryCheckmark;

}

 

相关文章:

  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-10-12
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-11-01
相关资源
相似解决方案