Question

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.

Was it helpful?

Solution

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:

enter image description here


Figure 5-2 Parts of a table-view cell in editing mode:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top