【问题标题】:Make the accessory type a checkmark for selected cell使附件类型成为选定单元格的复选标记
【发布时间】:2015-02-17 16:58:38
【问题描述】:

我正在尝试使(自定义UITableViewCell 的)选定单元格上有一个复选标记。我尝试了以下代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    CategorieCell *customCell = [tableView dequeueReusableCellWithIdentifier:@"cellID" forIndexPath:indexPath];

    if (customCell.accessoryType == UITableViewCellAccessoryDisclosureIndicator) {
        customCell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
        customCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
}

但是当我选择一个单元格时,什么都没有发生。

【问题讨论】:

    标签: ios objective-c uitableview didselectrowatindexpath accessorytype


    【解决方案1】:

    您的错误是您将新的自定义单元格出列。相反,您必须找出实际选中的单元格。将第一行更改为:

    CategorieCell *customCell = (CategorieCell *)[tableView cellForRowAtIndexPath:indexPath];
    

    应该就是这个了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-29
      • 2010-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多