I'm using the following code to determine if the last screen is visible on the screen to the user:
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == collection.count - 1 {
print("last cell is seen!!")
print(cell.frame)
}
}
This works on small screens where the user has to scroll to get to the desired cell. However, on large screens where the whole table is visible, this method doesn't work. Is there any way to determine the distance between bottom of screen to the last cell in the UITableView
?
Any help would be greatly appreciated. Thank you.
Edit: this is what I'm trying to accomplish.
if (last cell is visible && it is more than 100dp from bottom of screen) { display a fixed button on bottom of screen } else { add button to footer view of tableview so the user can scroll down to the button }