dequeueReusableCellWithIdentifier

来源:互联网 发布:知乎 恐怖提问 编辑:程序博客网 时间:2024/04/27 00:44

dequeueReusableCellWithIdentifier:

Returns a reusable table-view cell object located by its identifier.

- (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier

Parameters
identifier

A string identifying the cell object to be reused. By default, a reusable cell’s identifier is its class name, but you can change it to any arbitrary value.

Return Value

UITableViewCell object with the associated identifier or nil if no such object exists in the reusable-cell queue.

Discussion

For performance reasons, a table view’s data source should generally reuseUITableViewCell objects when it assigns cells to rows in itstableView:cellForRowAtIndexPath: method. A table view maintains a queue or list ofUITableViewCell objects that the table view’s delegate has marked for reuse. It marks a cell for reuse by assigning it a reuse identifier when it creates it (that is, in theinitWithFrame:reuseIdentifier: method of UITableViewCell). The data source can access specific “template” cell objects in this queue by invoking thedequeueReusableCellWithIdentifier: method. You can access a cell’s reuse identifier through its reuseIdentifier property, which is defined by UITableViewCell.

Availability
  • Available in iPhone OS 2.0 and later.
Related Sample Code
  • DrillDownSave
  • SimpleDrillDown
  • TableSearch
  • TableViewSuite
  • UICatalog
Declared In
UITableView.h

原创粉丝点击