[英]How to view the content UITableView's reusable pool
I was trying to deep dive into how the UITableView
works internally.我试图深入研究UITableView
内部是如何工作的。 I've already read multiple posts regarding that like,我已经阅读了多篇关于这样的帖子,
https://www.mikeash.com/pyblog/friday-qa-2013-02-22-lets-build-uitableview.html https://www.mikeash.com/pyblog/friday-qa-2013-02-22-lets-build-uitableview.html
I want to know if there is any way we can look into the content of the reusable pool , ie how many and what all UITableViewCell
types are available inside it at a moment.我想知道是否有任何方法可以查看可重用池的内容,即其中有多少以及所有UITableViewCell
类型在某一时刻可用。
I already know that we'll have the cells
as per the screen size and the cell
height .我已经知道我们将有cells
按照屏幕尺寸和cell
高度。 But I'm trying to figure out what happens if the tableView
accepts different types of cells
at different indexPaths
.但我试图弄清楚如果tableView
在不同的indexPaths
接受不同类型的cells
会发生什么。
Well, you can dig down into the objects in debug...好吧,您可以深入研究调试中的对象...
I set a breakpoint in didSelectRowAt
and looked into the Variables View pane:我在didSelectRowAt
设置了一个断点并查看了 Variables View 窗格:
I had one row (index path [0,3]
that used TestCellB
and 90 rows that used TestCell
, and the table was scrolled to row 21 (so row [0,3]
was well off-screen.我有一个行(索引路径[0,3]
所使用TestCellB
并且所使用90行TestCell
,并且该表被滚动到行21(这样的行[0,3]
殷实屏幕。
As you can see, there is an internal Dictionary
named _reusableTableCells
which, in my example, currently contains 1 TestCellB
and 2 TestCell
s.如您所见,有一个名为_reusableTableCells
的内部Dictionary
,在我的示例中,它当前包含1 个TestCellB
和2 个TestCell
。
EDIT编辑
I just gave this a try - might give you some additional info:我只是试了一下 - 可能会给你一些额外的信息:
var reusableCells = tableView.value(forKey: "_reusableTableCells")
print(reusableCells)
Output:输出:
Optional({
TestCellB = (
"<TranslateTest.TestCellB: 0x7f87b206aa00; baseClass = UITableViewCell; frame = (0 1612; 414 37); clipsToBounds = YES; hidden = YES; autoresize = W; layer = <CALayer: 0x600003a66380>>"
);
TestCellC = (
"<TranslateTest.TestCellC: 0x7f87b2894800; baseClass = UITableViewCell; frame = (0 205; 414 93); clipsToBounds = YES; hidden = YES; autoresize = W; layer = <CALayer: 0x600003a586e0>>",
"<TranslateTest.TestCellC: 0x7f87b3000e00; baseClass = UITableViewCell; frame = (0 298; 414 93); clipsToBounds = YES; hidden = YES; autoresize = W; layer = <CALayer: 0x600003a5fe40>>"
);
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.