gpt4 book ai didi

ios - 容器 View Controller 中的 tableviewcontroller : programatically selecting uitableviewcell, 突出显示闪烁

转载 作者:行者123 更新时间:2023-11-29 13:10:23 24 4
gpt4 key购买 nike

我正在尝试以编程方式突出显示表格 View 单元格并通过执行以下操作触发选择逻辑

NSIndexPath*indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[self tableView:self.tableView didSelectRowAtIndexPath:indexPath];

该行仅在一瞬间突出显示。我希望它一直突出显示,直到我选择另一行。

我尝试添加这些行

UITableViewCell *cell = [self.tableView cellForRowAtIndexPath: indexPath];
cell.highlighted = YES;

但是当我这样做时,即使我点击了另一行,突出显示仍然存在,并且直到我再次点击第一行才消失。

有什么想法吗?

最佳答案

尝试调用 selectRowAtIndexPath 而不是 didSelectRowAtIndexPath。我相信后者是前者的结果。如果您的委托(delegate)在 didSelectRowAtIndexPath 中取消选择最后选择的索引路径,那么两次调用将导致取消选择您刚刚选择的内容

关于ios - 容器 View Controller 中的 tableviewcontroller : programatically selecting uitableviewcell, 突出显示闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17559164/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com