'tableView.contentSize'和'tableView.frame.size'之间的区别是什么?

Bar*_*zyk 7 frame uitableview uiscrollview ios contentsize

tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true)
Run Code Online (Sandbox Code Playgroud)

它的工作原理,但我不知道究竟是这两个值: tableView.contentSize,tableView.frame.size

tba*_*nes 15

contentSize是对内容的大小UIScrollView,这意味着这将是内容(隐藏和可见)的大小,而frame.size你的tableView的真实尺寸.

例如,假设我的设备屏幕为568(高度),在其中,我有一个UITableView(占据所有屏幕)100个单元格,每个高度为50.我tableView.frame.size.height将等于568,但是tableView.contentSize.height它将等于所有单元格的卷轴大小,所以5000.

另外,正如@Ethaan所建议的那样,请阅读此内容以便更深入.