Why would a table view not allow me to select its rows? I have programmatically set the isUserInteractionEnabled and allowsSelection properties to true and have set the table view cell's isUserInteractionEnabled property to true.
The table view is able to scroll, and I noticed that the row becomes selected when I tap on the label on the cell, but it does not become selected when I tap on the text view on the cell.
I am totally stumped on this one.
Here is my relevant code:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
tableView.dataSource = self
tableView.delegate = self
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 44
tableView.allowsSelection = true
tableView.isUserInteractionEnabled = true
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: DatabaseNameStrings.recordTypeMessage, predicate: predicate)
privateDatabase.perform(query, inZoneWith: nil) {
records, error in
if error != nil {
print(error!.localizedDescription)
} else {
for record in records! {
let utiMessage = UTIMessage(ckRecord: record)
self.messages.append(utiMessage)
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}
// MARK: - UITableViewDataSource
extension CreateMessagesViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return messages.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "messageCell", for: indexPath) as! MessageTableViewCell
let message = messages[indexPath.row]
cell.labelTitle.text = message.title
cell.textViewBody.text = message.body
return cell
}
}
// MARK: - UITableViewDelegate
extension CreateMessagesViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("didSelectRowAt")
}
}