ios - IOS/Swift:使表格视图单元格不可选择,但表格视图仍可在 Swift 中滚动
问题描述
我想让 tableView 的单元格不可选择,但仍允许滚动。当我放置
tableView.isUserInteractionEnabled = false
这在某些答案中被推荐viewDidLoad
,它可以防止选择但也可以防止滚动。
添加:
cell.selectionStyle = .none
如下所示cellforrowatindexpath
对我没有任何影响。
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
self.tableView.beginUpdates()
self.tableView.endUpdates()
if let cell = tableView.dequeueReusableCell(withIdentifier: "myMessageCell", for: indexPath) as? myMessageCell {
cell.message = messages[indexPath.row]
cell.selectionStyle = .none
}
return tableView.dequeueReusableCell(withIdentifier: "myMessageCell", for: indexPath)
}
谁能建议如何在不阻止滚动的情况下阻止选择?
在此先感谢您的任何建议。
解决方案
希望你正在寻找这个:
tableView.allowsSelection = false
推荐阅读
- c# - 无结构对象的序列化
- mongodb - MongoDB modifiedCount 不等于matchedCount
- javascript - Chrome.storage.local.get 在 React 中返回未定义?
- elasticsearch - Scroll API 返回的 Scroll id 太长
- c# - 如何在文件 asp.net 中下载 json 对象
- html - 选择所有电台时如何自动提交?
- spring - 如何使用 Spring Cloud Stream Binder 动态创建 Azure 服务总线订阅?
- php - Guzzle POST 返回 GuzzleHttp\Exception\ClientException 客户端错误:`POST
- android - 如何在片段内完成任务之前禁用后退按钮功能?
- python - Pandas - 在固定位置生成字符串排列