如何到达didSelectRowAtIndexPath中当前选定的单元格?
我想通过didSelectRowAtIndexPath方法更改单元格的辅助视图types,即当select一行时,我想更改辅助视图types,我可以在该方法内部执行此操作吗?
您可以像这样使用indexPath从didSelectRowAtIndexPath:方法获得单元格。
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; { UITableViewCell *myCell = [tableView cellForRowAtIndexPath:indexPath]; // Access accessory View as below. UIView * myCellAccessoryView = myCell.accessoryView; } 
使用下面的函数并传递选定行的索引path,以便特定的单元格重新加载。
 - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 
 另一个解决scheme:存储选定的行索引,并重新加载tableview。 然后在cellForRowAtIndexPath检查选定的行并更改单元的附件视图。 
迅速
您可以使用indexPath从didSelectRowAtIndexPath:方法获取单元格,如下所示:
  let cell:UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) 
在Swift 3.0中 :你可以根据你的需要使用这两种方法
  let cell:UITableViewCell = tableView.cellForRow(at: indexPath) as UITableViewCell 
要么
 let cell:CustomTableViewCell = tableView.cellForRow(at: indexPath) as! CustomTableViewCell 
快乐编码!
存储选定的索引path。 例如:NSInteger selectedIndexPath; 然后按照下面的步骤。 设置你的配件视图。
 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { AddressTableViewCell *cell=(AddressTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; cell.backgroundColor=[UIColor lightGrayColor]; Address *addr=[self.locationArray objectAtIndex:indexPath.row]; cell.titleLabel.text = addr.addressTitle; cell.detailLabel.text = addr.addressDetail; if (indexPath.row == selectedIndexPath) { [cell.selectButton setImage:[UIImage imageNamed:@"checkboxFilled"] forState:UIControlStateNormal]; } else { [cell.selectButton setImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal]; } return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ selectedIndexPath=indexPath.row; [self.tableView reloadData]; }