What is the difference between 'tableView.contentSize' and 'tableView.frame.size'
Asked Answered
G

1

10
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

Greatniece answered 29/1, 2015 at 10:11 Comment(2)
It's related to the 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
if you wanna go deep, take a look on thisDunson
W
22

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.

Wilonah answered 29/1, 2015 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.