gpt4 book ai didi

ios - 如何禁用 UITableView 选择?

转载 作者:IT王子 更新时间:2023-10-29 07:24:07 25 4
gpt4 key购买 nike

当您点击 UITableView 中的一行时,该行会突出显示并被选中。是否可以禁用此功能以便点击一行什么都不做?

最佳答案

您所要做的就是使用以下任一方法在 UITableViewCell 实例上设置选择样式:

objective-C :

cell.selectionStyle = UITableViewCellSelectionStyleNone;

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

swift 2:

cell.selectionStyle = UITableViewCellSelectionStyle.None

swift 3 和 4.x:

cell.selectionStyle = .none

此外,请确保您没有在 TableView 委托(delegate)中实现 -tableView:didSelectRowAtIndexPath:,或者如果您实现了它,则明确排除您不希望有任何操作的单元格。

More info herehere

关于ios - 如何禁用 UITableView 选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/190908/

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