【问题标题】:Table view cells do not lose highlight on touch up表格视图单元格在修饰时不会失去突出显示
【发布时间】:2012-05-09 02:17:40
【问题描述】:

当我单击它选择的单元格时,它在修饰时保持蓝色。我希望蓝色突出显示在修饰时留下(但重要的是它首先突出显示)。

最后一个答案in this post 提到了一些关于willSelectRowAtIndexPath: 的内容,但我不知道如何使用它来做我想做的事。另外,我确实需要didSelectRowAtIndexPath: 才能被调用,我只是希望单元格在修饰时不突出显示。

【问题讨论】:

    标签: objective-c cocoa-touch uitableview


    【解决方案1】:

    在适当的地方使用以下内容:

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    

    例如在didSelectRowAtIndexPath:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
          [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }
    

    这将取消选择指定索引路径处的行。

    您也可能对UITableViewController 中的clearsSelectionOnViewWillAppear 属性感兴趣。如果此属性设置为 yes,则控制器会在表格出现时清除选择。默认情况下它设置为 YES。

    Reference.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多