I am working on a UITableView
with a custom row (single row), that I load from a separate xib
file. UITableView
also has a sticky footer view
.
Everything is working fine except that when I tap on the footer view
, the UITableView's
delegate method tableView(_:didSelectRowAt:)
is being called, and that's weird.
The IndexPath
that I received inside that method is [0,0]. Now how that is problematic for me? Well I am doing a certain thing when the cell of that tableview is pressed. But under the current scenario, that certain thing is also being done when I press footer view instead of the cell.
The code for UITableView is:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(
withIdentifier: CellIdentifiers.INVITE_CELL_ID,
for: indexPath) as? InviteCell else {
return UITableViewCell()
}
// cell configuration
return cell
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (contacts.count > 0) {
guard let footer = tableView.dequeueReusableCell(
withIdentifier: CellIdentifiers.INVITE_FOOTER_CELL_ID)
as? InviteFooter else {
return nil
}
footer.delegate = self
return footer
}
return nil
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if (contacts.count > 0) {
return 90
}
return 0
}