iphoneiosuitableviewaccessorytype

is there an easy way to have a UITableView highlight which row is selected to a user via a disclosure indicator?


is there an easy way to have a UITableView highlight which row is selected to a user via a disclosure indicator?

That if row 3 was selected then after row 10 was selected (only one row can be selected at a time say), then:

  1. disclosure indicator for row 3 should disappear
  2. disclosure indicator for row 10 should then appear

Solution

  • Try this one , here count_of_rows is the count of array from which you are populating the table .

      -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath
     {
        UITableViewCell * cell = [table cellForRowAtIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
        int selectedRow = indexPath.row;
    
        for(int i=0 ; i < count_of_rows ; i++)
        {
            if(i != selectedRow)
            {
                         UITableViewCell * c= [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:1]]
                         c.accessoryType = UITableViewCellAccessoryNone;
    
    
            }
        }
    }