开发者社区 问答 正文

怎样取消UITableViewCell的选中状态?

点击Cell是被选中的cell的背景会是灰色的,怎样取消Cell 的选中状态?

展开
收起
a123456678 2016-07-28 11:32:10 2060 分享 版权
1 条回答
写回答
取消 提交回答
  • 只需要在- (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath中加入一行代码就可以了[tableView deselectRowAtIndexPath:indexPath animated:YES]; 然后再写你其他代码就可以了

    • (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath
      {

      [tableView deselectRowAtIndexPath:indexPath animated:YES];// 取消选中
      //其他代码

      }

    2019-07-17 20:01:15
    赞同 展开评论
问答地址: