tableview.cellforrow(在indexpath处)在ios swift的DIDSelectRow中返回nil
我试图找到选定的单元格。在tableview.cellforrow(在indexpath处)在ios swift的DIDSelectRow中返回nil,ios,swift,uitableview,tableview,Ios,Swift,Uitableview,Tableview,我试图找到选定的单元格。在中选择rowat功能。但是cellForRowAt返回nil值 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let _ = self.tableView.cellForRow(at: indexPath) as? ChatListTableViewCell else { return } } 请
中选择rowat
功能。但是cellForRowAt
返回nil值
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let _ = self.tableView.cellForRow(at: indexPath) as? ChatListTableViewCell else {
return }
}
请显示
cellforrowatinex
方法的代码使用UITableView
的indexPathForSelectedRow
方法。是否验证cellForRow
函数是否真的返回nil?guard let可能也会失败,因为找到的单元格无法强制转换为ChatListTableViewCell
。请显示cellForRowAtIndex
methodUseUITableView
的indexPathForSelectedRow
方法的代码。是否验证cellForRow
函数是否真的返回零?guard let可能也会失败,因为找到的单元格无法转换为ChatListTableViewCell
。