Graphics Programs Reference
In-Depth Information
Creating HomepwnerItemCell
UITableViewCell is a UIView subclass. When subclassing UIView (or any of its
subclasses), you typically override its drawRect: method to customize the view's ap-
pearance. However, when subclassing UITableViewCell , you don't change the cell's
appearance directly.
Each cell has a subview named contentView , which is a container for the view objects
that make up the layout of a cell subclass ( Figure 15.2 ). You subclass UIT-
ableViewCell by changing the view objects in a cell's contentView . For instance,
you could create instances of the classes UITextField , UILabel , and UIButton and
add them to the contentView . (If you wanted something even more daring, you could
create a UIView subclass, override its drawRect: , and add an instance of it to the con-
tentView .)
Figure 15.2 HomepwnerItemCell hierarchy
Adding subviews to the contentView instead of directly to the UITableViewCell
subclass is important because the cell will resize the contentView at certain times. For
example, when a table view enters editing mode, the contentView resizes itself to make
room for the editing controls ( Figure 15.3 ). If you were to add subviews directly to the
 
Search WWH ::




Custom Search