Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen creating my UITableViewCells, why is the init never called? (Resulting in blank cells?)
    primarykey
    data
    text
    <p>In my UITableView, I recently changed the structure of the cell from formerly just putting UILabels in the contentView of the cell, to adding two UIViews (CellFront and CellBack, on top of one another) into the contentView (so I can achieve a sliding effect by sliding the top one off and revealing the lower one) and adding the UILabels to the top UIView.</p> <p>However, now, for whatever reason, the cells never get init'd and as a result my UITableView is full of blank cells.</p> <p>My cell gets created as follows (ArticleCell is a subclass of UITableViewCell):</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = nil; ArticleInfo *articleInfo = [self.fetchedResultsController objectAtIndexPath:indexPath]; // Checks if user simply added a body of text (not from a source or URL) if ([articleInfo.isUserAddedText isEqualToNumber:@(YES)]) { CellIdentifier = @"BasicArticleCell"; } else { CellIdentifier = @"FullArticleCell"; } ArticleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[ArticleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } // If the user simply added a body of text, only articlePreview and progress has to be set cell.preview = articleInfo.preview; // If it's from a URL or a source, set title and URL as well if ([articleInfo.isUserAddedText isEqualToNumber:@(NO)]) { cell.title = articleInfo.title; cell.URL = articleInfo.url; } return cell; } </code></pre> <p>But I set a breakpoint on the initWithStyle method above within the if statement and it never gets called:</p> <p><img src="https://i.stack.imgur.com/RY9zy.png" alt="enter image description here"></p> <p>What would cause this? I'm deleting the app and building it from scratch every time, so data is definitely being added to the UITableView, but all the cells are blank. And I can tell a bunch of cells are being added as I have disclosure indicators on all of them, and the table view just gets filled with empty cells with the indicators only.</p> <p><img src="https://i.stack.imgur.com/gYA3k.png" alt="enter image description here"></p> <p>What am I doing wrong?</p>
    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.
 

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