为什么 UITableViewCell 有 contentView 属性?
这个 contentView 属性有什么意义?我的意思是:为什么不将所有子视图都添加到 self 中?
让我正确地说:每个单元格都是一个视图(UITabvleViewCell 是 UIView 子类)。这个胖视图上面有另一个具有相同边界的胖视图,称为 contentView。然后,该 contentView 携带所有其他子视图。
现在他们为什么不保存那块额外的内存呢?这个决定背后是否有什么天才的逻辑?很想了解其中的原因。
What's the point of this contentView property? I mean: Why aren't all the subviews just added to self
?
Let me get that right: Every cell is a view (UITabvleViewCell is a UIView subclass). And this fat view has another fat view with same bounds sitting on top of it, called contentView. That contentView then carries all those other subviews.
Now why didn't they save that extra chunk of memory? Is there any genius logic behind this decision? Would love to understand the reason for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
内容视图并不总是与单元格具有相同的边界。例如,当进入编辑模式时,删除按钮会将内容视图向右滑动,并在此过程中调整其大小。
来自仔细看看表格视图单元格
图 5-1 表视图单元格的部分:
图 5-2 编辑模式下的表格视图单元格的各个部分:
The content view does not always have the same bounds as the cell. For instance, when entering editing mode, the delete button slides the content view to the right, resizing it in the process.
From A Closer Look at Table View Cells
Figure 5-1 Parts of a table view cell:
Figure 5-2 Parts of a table-view cell in editing mode: