Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between 'tableView.contentSize' and '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

like image 353
Bartłomiej Semańczyk Avatar asked Jan 29 '15 10:01

Bartłomiej Semańczyk


1 Answers

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.

like image 58
tbaranes Avatar answered Nov 15 '22 18:11

tbaranes