gpt4 book ai didi

iphone - 当用户返回 View Controller 时如何取消选择 uitableview 单元格

转载 作者:IT老高 更新时间:2023-10-28 11:39:06 26 4
gpt4 key购买 nike

当用户选择它时,我有一个 uitableview 单元格突出显示,然后被推送到详细 View 。我希望单元格在返回表格 View View Controller 时不突出显示。

我将如何完成这项工作?

我在 viewWillAppear 中猜测 [cell.textLabel setHighlighted:NO];,但如果我把它放在那里,单元格是未声明的。

感谢您的帮助

最佳答案

如果您使用 UITableViewController 子类,那么只需设置属性

self.clearsSelectionOnViewWillAppear = YES;

else in viewWillAppear 只需调用

NSIndexPath *indexPath = self.tableView.indexPathForSelectedRow;
if (indexPath) {
[self.tableView deselectRowAtIndexPath:indexPath animated:animated];
}

// MARK: - Swift 3
if let indexPath = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: indexPath, animated: true)
}

关于iphone - 当用户返回 View Controller 时如何取消选择 uitableview 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14956823/

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