从行中删除表附件指示符

Den*_*Vog 4 iphone uitableview ipad accessorytype ios

有没有办法从行中单独禁用辅助指示器?我有一张桌子使用

- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewCellAccessoryDetailDisclosureButton;
    }
Run Code Online (Sandbox Code Playgroud)

我需要为单行禁用它(删除图标而不触发详细信息泄露事件).我以为这会做到,但没有结果.该指示器仍然出现,它仍然接收和触摸事件.

cell.accessoryType = UITableViewCellAccessoryNone;
Run Code Online (Sandbox Code Playgroud)

谢谢你的任何建议.

Suj*_*yam 14

那个函数调用'accessoryTypeForRow ..'现在已经过时了(来自sdk 3.0 +).

设置附件类型的首选方法是'cellForRowAt ..'方法

- (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;
}
Run Code Online (Sandbox Code Playgroud)