I would like to make the cells of a tableView non-selectable but still allow scrolling. When I placed
tableView.isUserInteractionEnabled = false
which is recommended in some answers in viewDidLoad
, it prevents selection but also prevents scrolling.
Adding:
cell.selectionStyle = .none
in cellforrowatindexpath
as below not have any effect for me.
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)
}
Can anyone suggest how to prevent selection without preventing scrolling?
Thanks in advance for any suggestions.