Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView Cells Empty
    text
    copied!<p>Im having a real issue with my UITableView, let me walk you through it.</p> <p>I have a UITableViewController in my storyboard which has four different prototype cells each with their own identifiers.</p> <p>Then I have this in my class for the controller:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"name"; if (indexPath.section == 0) CellIdentifier = @"name"; else if (indexPath.section == 1) CellIdentifier = @"name"; else if (indexPath.section == 2 &amp;&amp; indexPath.row == 0) CellIdentifier = @"segment"; else if (indexPath.section == 2 &amp;&amp; (indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 3)) CellIdentifier = @"switch"; else if (indexPath.section == 3) CellIdentifier = @"segment"; else if (indexPath.section == 4) CellIdentifier = @"segment2"; else if (indexPath.section == 5) CellIdentifier = @"name"; else if (indexPath.section == 6) CellIdentifier = @"name"; else if (indexPath.section == 7) CellIdentifier = @"name"; GuestDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[GuestDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } //Configure my cells here, like so: if (indexPath.section == 0) { cell.title.text = @"title"; } else if (indexPath.section == 1) { } //etc return cell; } </code></pre> <p>I think this is where my problem lies, as I have had success with some different code (which I will add if you might need to see it, let me know.</p> <p>The right number of cells show in the table and right number of sections and if you select a cell it takes you to the right sub-viewcontroller, but the actual cells themselves are just blank. Why might they all be returning nil?</p> <p>Now when the view is shown, all the cells are blank. <code>cell = [[GuestDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];</code> This seems to be called over and over, opposed to my cells as configured showing.</p> <p>I get to this view by calling this code:</p> <pre><code>- (void)addNewGuest { newGuestViewController *addGuestViewController = [[newGuestViewController alloc] initWithStyle:UITableViewStylePlain]; addGuestViewController.delegate = self; //Create a new managed object context for the new guest -- set its persistent store coordinator to the same as that from the fetched results controller's context. NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init]; self.addingManagedObjectContext = addingContext; [addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]]; addGuestViewController.guest = (GuestInfo *)[NSEntityDescription insertNewObjectForEntityForName:@"GuestInfo" inManagedObjectContext:addingContext]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addGuestViewController]; [self.navigationController presentModalViewController:navController animated:YES]; } </code></pre> <p>Any ideas, or need more info?</p> <p>Thanks.</p>
 

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