Contents

initWithFrame:reuseIdentifier:

Initializes and returns a table cell object.

Declaration

- (id) initWithFrame:(CGRect) frame reuseIdentifier:(NSString *) reuseIdentifier;

Parameters

  • frame:

    The frame rectangle of the cell. Because the table view automatically positions the cell and makes it the optimal size, you can pass in CGRectZero in most cases. However, if you have a custom cell with multiple subviews, each with its own autoresizing mask, you must specify a non-zero frame rectangle; this allows the table view to position the subviews automatically as the cell changes size.

  • reuseIdentifier:

    A string used to identify the cell object if it is to be reused for drawing multiple rows of a table view. Pass nil if the cell object is not to be reused.

Return Value

An initialized UITableViewCell object or nil if the object could not be created.

Discussion

This method is the designated initializer for the class. The reuse identifier is associated with those cells (rows) of a table view that have the same general configuration, minus cell content. In its implementation of tableView(_:cellForRowAt:), the table view’s delegate calls the UITableView method dequeueReusableCell(withIdentifier:), passing in a reuse identifier, to obtain the cell object to use as the basis for the current row.

See Also

Related Documentation

Deprecated