Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView with two custom cells (multiple identifiers)
    primarykey
    data
    text
    <p>I am trying to put a cell as a space between each cell - which will be hidden by setting alpha = 0. In my table, the space cells will be for rows that are odd.</p> <p>Note that the actual cell height is 85, but the hidden cell height (ie space between cells) is 20.</p> <p>The problem is that the space cell height is 85, but not 20, I don't know why. Maybe the cell is not loaded correctly.</p> <p><code>Cell</code> here is the <code>UITableViewCell</code> - the actual cell - with identifier 'Cell'.</p> <p><code>Cell2</code> is the space with identifier 'Space'.</p> <p>Each class above has its own <code>UITableViewCell</code> class and the XIB files are also assigned to each of them. The <em>identifier</em> is also set in the IB for each Xib.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier1 = @"Cell"; static NSString *CellIdentifier2 = @"Space"; Cell *cell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; if(!cell) { NSArray *ar = [[NSBundle mainBundle] loadNibNamed:@"CellView" owner:nil options:nil]; for (id obj in ar) { if ([obj isKindOfClass:[Cell class]]) { cell = (Cell *)obj; break; } } } if (indexPath.row % 2 == 1) { Cell2 *cell2 = (Cell2 *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; if (!cell2) { NSArray *ar = [[NSBundle mainBundle] loadNibNamed:@"Cell2" owner:nil options:nil]; for(id obj in ar) { if([obj isKindOfClass:[Cell2 class]]) { cell2 = (Cell2 *)obj; break; } } // Method 1 cell2 = [[Cell2 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2]; // Method 2 //cell2 = [[Cell2 alloc] init]; // Method 3 //cell2 = (Cell2 *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; [cell2.contentView setAlpha:0]; // prevent selection and other stuff [cell2 setUserInteractionEnabled:NO]; } return cell2; } else { // Configure the actual cell } return cell; </code></pre> <p>}</p>
    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.
 

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