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

标签 ios uitableview containment

我正在尝试以编程方式突出显示表格 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/

相关文章:

ios - 格式化轴标签核心图的长数字

ios - 真实 iPhone 上的 rn-fetch-blob 无法上传图像(本地主机测试)

iOS Assistive Touch 用黑色补丁弄乱屏幕

ios - Apple 建议使用 : custom struct or extension? 是什么

ios - TableView 的一种方法,仅在第一次显示 View 时调用

ios - 在表格 View 单元格中显示旧图像

ios - NSManagedObject 循环返回重复项 Swift

c++ - 子对象和包含对象之间的区别

eclipse - 包含与引用之间的ECore有什么区别?