Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're not already familiar with loading a custom cell from a xib, check out the <a href="http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW20" rel="nofollow">documentation here</a>. To extend this to multiple custom xibs, you can create each table cell in a separate xib, give it a unique cell identifier, set the table view controller as the file's owner, and connect each cell to the custom cell outlet you define (in the docs, they use <code>tvCell</code> as this outlet). Then in your <code>-tableView:cellForRowAtIndexPath:</code> method, you can load the correct xib (or dequeue the correct reuseable cell) by checking which row you're providing a cell for. For example:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier1 = @"MyIdentifier1"; static NSString *MyIdentifier2 = @"MyIdentifier2"; static NSString *MyIdentifier3 = @"MyIdentifier3"; static NSString *MyIdentifier4 = @"MyIdentifier4"; NSUInteger row = indexPath.row UITableViewCell *cell = nil; if (row == 0) { cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer1]; if (nil == cell) { [[NSBundle mainBundle] loadNibNamed:@"MyTableCell1" owner:self options:nil]; cell = self.tvCell; self.tvCell = nil; } } else if (row == 1) { cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer2]; if (nil == cell) { [[NSBundle mainBundle] loadNibNamed:@"MyTableCell2" owner:self options:nil]; cell = self.tvCell; self.tvCell = nil; } } else if (row == 2) { cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer3]; if (nil == cell) { [[NSBundle mainBundle] loadNibNamed:@"MyTableCell3" owner:self options:nil]; cell = self.tvCell; self.tvCell = nil; } } else if (row == 4) { cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer4]; if (nil == cell) { [[NSBundle mainBundle] loadNibNamed:@"MyTableCell4" owner:self options:nil]; cell = self.tvCell; self.tvCell = nil; } } // etc. // Do any other custom set up for your cell return cell; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload