iOS:在索引路径的did select行中打勾

iOS:在索引路径的did select行中打勾,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在做与tableview相关的iOS应用程序,它在tableview的左侧包含复选标记。我保留了图像视图而不是原型单元格,当选中tableview单元格时,会出现一个选中的图像,当再次选中时,选中的图像会消失。这是我的代码 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier

我正在做与tableview相关的iOS应用程序,它在tableview的左侧包含复选标记。我保留了图像视图而不是原型单元格,当选中tableview单元格时,会出现一个选中的图像,当再次选中时,选中的图像会消失。这是我的代码

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

  {

static NSString *CellIdentifier = @"Cell";


Contact_customCell *cell = [self.tableview cellForRowAtIndexPath:[tableView indexPathForSelectedRow]];
if (cell == nil) {
    cell = [[Contact_customCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
   if([tableView  indexPathForSelectedRow])

           if([indexPath.row )
           {
               cell.imageView.image=[UIImage imageNamed:@"Selected"];
           }
            else
                       {
               cell.imageView.image=[UIImage imageNamed:@"Unselected"];
           }
  }

请提供帮助。

图像的设置基于
if([indexPath.row)
而不是单元格的先前图像设置

如果用户轻触第一个单元格(索引行零),则图像将始终为
[UIImage imageNamed:@“Unselected”];

如果用户点击任何其他单元格,图像将
[UIImage imageNamed:@“Selected”];

代码需要从单元格中获取当前设置,然后设置适当的图像