DenVog DenVog - 1 year ago 95
iOS Question

Remove Table Accessory Indicator from Row

Is there a way to disable accessory indicators from rows individually? I have a table that uses

- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
return UITableViewCellAccessoryDetailDisclosureButton;

I need to disable it (remove icon and not trigger a detail disclosure event) for a single row.
I thought this would do it, but has no result. The indicator still appears and it still receives and event on touch.

cell.accessoryType = UITableViewCellAccessoryNone;

Thanks for any suggestions.

Answer Source

That function call 'accessoryTypeForRow..' is depeecated now (from sdk 3.0 +).

Preferred way of setting the accessory type is in 'cellForRowAt..' method

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"SomeCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

    // customize the cell
     cell.textLabel.text = @"Booyah";
    // sample condition : disable accessory for first row only...
     if (indexPath.row == 0)
         cell.accessoryType = UITableViewCellAccessoryNone;

     return cell;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download