I want to change the accessory view type of a cell through the method: didSelectRowAtIndexPath , i.e. when a row is selected I want to change the accessory view type, can I do t
Store selected indexpath. for eg: NSInteger selectedIndexPath; then follow the step below. set your accessory view.
-(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];
}