I use the following code to determine if the last window on the screen is displayed:
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 entire table is visible, this method does not work. Is there a way to determine the distance between the bottom of the screen to the last cell in UITableView?
Any help would be greatly appreciated. Thank.
Edit: this is what I'm trying to accomplish.
if (the last cell && is visible more than 100dp from the bottom of the screen) {display a fixed button at the bottom of the screen} else {add a button to the table view footer so that the user can scroll down to the button}