gpt4 book ai didi

iphone - 如何在iphone sdk上设置uitableviewcell不可点击

转载 作者:行者123 更新时间:2023-12-03 18:26:21 24 4
gpt4 key购买 nike

您好,我正在尝试将我的 uitableviewcell 呈现为非事件状态,以便用户无法单击而只能说出单元格中的数据。我尝试这样做:

UITableViewCell *cell = nil;
if (indexPath.row < factsCount) {
static NSString *FactsCellIdentifier = @"FactsCell";
cell = [tableView dequeueReusableCellWithIdentifier:FactsCellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

但是,仍然可以单击并突出显示单元格。

感谢您的帮助!

最佳答案

要停止仅选择某些单元格,请使用:

cell.userInteractionEnabled = NO;

除了阻止选择之外,这还会阻止为设置了该选项的单元格调用 tableView:didSelectRowAtIndexPath: 。

(但请注意,它将禁用单元格内的任何交互式内容 - 例如按钮 - 对于这种情况,请将 SelectionStyle 设置为 UITableViewCellSelectionStyleNone 并忽略 tableView:didSelectRowAtIndexPath: 对该单元格的调用)

关于iphone - 如何在iphone sdk上设置uitableviewcell不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2051210/

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