ios - How to determine if the last cell of a UITableView is visible on the screen -
i'm using following code determine if last screen visible on screen user:
override func tableview(_ tableview: uitableview, willdisplay cell: uitableviewcell, forrowat indexpath: indexpath) { if indexpath.row == collection.count - 1 { print("last cell seen!!") print(cell.frame) } }
this works on small screens user has scroll desired cell. however, on large screens whole table visible, method doesn't work. there way determine distance between bottom of screen last cell in uitableview
?
any appreciated. thank you.
edit: i'm trying accomplish.
if (last cell visible && more 100dp bottom of screen) { display fixed button on bottom of screen } else { add button footer view of tableview user can scroll down button }
you can use method see if last cell visible or not
func iscellvisible(section:int, row: int) -> bool { guard let indexes = self.indexpathsforvisiblerows else { return false } return indexes.contains {$0.section == section && $0.row == row } } }
then can call
let lastcell = collection.count - 1 let result = iscellvisible(section:"your section number", row: lastcell)
Comments
Post a Comment