gpt4 book ai didi

iphone - 取消选择 UITableView 中的 subview 行

转载 作者:行者123 更新时间:2023-12-03 19:30:45 24 4
gpt4 key购买 nike

我有一个 UITableView,它作为 subview 添加到 View 中。选择一行时,将出现一个带有 pushViewController: 的新 View ,并且用户可以选择按后退按钮返回 UITableView,但单元格仍处于选中状态。

有没有办法在 View 出现时取消选择此选项?

我已经读到我应该使用以下代码,但我无法让它工作。没有错误,没有警告,什么也没有。

[tableProgram deselectRowAtIndexPath:[tableProgram indexPathForSelectedRow]animated:NO];

最佳答案

您应该在 UITableView 委托(delegate)的 didSelectRowAtIndextPath 方法中取消选择该行。它应该看起来像这样。

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

/* initialize your view controller here v and then push it */
SomeViewController *v = [[[SomeViewController alloc] init] autorelease];
[self.navigationController pushViewController:v animated:YES];
}

不要将它与 didDeselectRowAtIndextPath 方法混淆 - 这是因为人们在从 intelisense 选择方法时没有太注意。

关于iphone - 取消选择 UITableView 中的 subview 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5370012/

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