Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>* I've renamed some of your NIB/Class names for a better understanding. *</strong></p> <p>First, you should register each cells' NIB:</p> <pre><code>- (void)viewDidLoad{ [super viewDidLoad]; static NSString *CellIdentifier1 = @"ContentCell"; static NSString *CellIdentifier2 = @"SpaceCell"; UINib *nib = [UINib nibWithNibName:@"CellViewNIBName" bundle:nil]; [self.tableView registerNib:nib forCellReuseIdentifier:CellIdentifier1]; nib = [UINib nibWithNibName:@"CellSpaceNIBName" bundle:nil]; [self.tableView registerNib:nib forCellReuseIdentifier:CellIdentifier2]; self.contentView.hidden = YES; [self loadData]; } </code></pre> <p>Because you have the NIBs registered, <code>dequeueReusableCellWithIdentifier:</code> will always return a cell:</p> <pre><code>- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier1 = @"ContentCell"; static NSString *CellIdentifier2 = @"SpaceCell"; // Space Cell if (indexPath.row % 2 == 1) { CellSpace *cell = (CellSpace *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; return cell; } // Content cell else { CellView *cell = (CellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; // Configure cell return cell; } } </code></pre> <p>Last, but not least, make sure to implement the following delegate method:</p> <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { // Space cell's height if (indexPath.row % 2 == 1) { return 20.0f; } // Content cell's height else { return 80.0f; } } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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