tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true)
It works, but I wonder what actually are those two values:
tableView.contentSize
, tableView.frame.size
tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true)
It works, but I wonder what actually are those two values:
tableView.contentSize
, tableView.frame.size
The contentSize
is the size of the content of the UIScrollView
, that means it will be the size of the content (hidden and visible) whereas the frame.size
is the real size of your tableView.
For example, let's say I have a device's screen of 568 (height), and inside it, I have an UITableView
(taking all the screen) with 100 cells and an height of 50 for each of them. My tableView.frame.size.height
will be equal to 568, but the tableView.contentSize.height
will be equal of the scroll's size of all the cells, so 5000.
Also, as suggested by @Ethaan, read this to go deeper.
© 2022 - 2024 — McMap. All rights reserved.
UIScrollView
part, about what's actually shown and what's the whole size in reality (counting the "hidden" content, not shown except if you scroll) – Victoria