gpt4 book ai didi

ios - 禁用所有 UITableViewCells 用户交互

转载 作者:搜寻专家 更新时间:2023-11-01 06:18:27 26 4
gpt4 key购买 nike

嘿,我有一个 UITableView。有 4 个大单元格(因此它们并没有全部显示在屏幕上)。在应用程序的不同点上,我想为所有这些禁用用户交互,但是当我运行此代码时出现 nil unwrap 错误:

for row in 0...3 {
let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: row, inSection: 2)) as! AnswerTextChoiceCell
cell.userInteractionEnabled = reEnable ? true : false
}

我猜这是因为它无法获取单元格,因为它没有显示在屏幕上。我将如何禁用所有单元格的所有用户交互?

I don't want to disable the user interaction on the tableView as it will prevent the user from scrolling.

如有任何建议,我们将不胜感激!

最佳答案

尝试一次。

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//Configure the cell

if indexPath.row == yourcell {
cell.userInteractionEnabled = false
}
return cell!
}

希望这对您有所帮助。

关于ios - 禁用所有 UITableViewCells 用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39164006/

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