Note that there are some explanatory texts on larger screens.

plurals
  1. POUISearchDisplayController—why does my search result view contain empty cells?
    primarykey
    data
    text
    <p>I am about to go out of my mind here, in my Core Data databse I have a lot of users, i have hooked the database up to a tableviewcontroller via NSFetchedResultController, and when the view loads, I see all my users, and i can perform a push to a detail viewcontroller via storyboard segue... so far so god, my tableview contains a custom cell with an image view and 2 uitextlabels that all has their tag values assigned..</p> <p>Now, when I perform the search I create a new NSFetchedResultController with a predicate, and performs the performFetch.. I then get the fetchedObjects property and it contains the users that match, so the search request is also working like a charm.. in all my tableviews datasources I check if self.tableView == self.searchdispl.view to see which controller I should query data from.. In all the controllers delegates I check to see which controller is active so i know which view to reload. If i nslog a lot of data it is all fine behind the scenes, the delegate and datasource methods all use the correct view and fetchcontroller..</p> <p>In my cellForRowAtIndexPath i can log out my user.name, and that is always correct, also when searching.</p> <p>The issue is that the UISearchDisplayController view that is on top only has empty cells, unless i set my UITableViewControllers dynamic prototype cell to basic, then both tableviews contain that label with the users name ! The segue from the cell still doesn't work, but there is data in the cell.</p> <p>It seems as the UISearchDisplayControllers view is a generic view, at least when it comes to segues and cell layout...</p> <p>I have checked all the connections from the UISearchDisplayController to my UITableViewController, and all looks fine...</p> <p>Why will the SearchDisplayControllers view not accept my cell layout and segue ?</p> <p>Thank you :)</p> <p>Update : has just figured out what is going wrong, but not found the solution yet. In my cellForRowAtIndexPath the cell is always configured as the Default Cell when thr searchdisplayview is in this method.. Do i really need to create my cell in code for the uisearchdisplay to work ? Why can it not use the configured cell from the storyboard ?</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"PersonCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSLog(@"Default Cell"); cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } NSFetchedResultsController *controller = tableView == self.tableView ? self.fetchedResultsController : self.fetchedResultsControllerForSearch; Person *p; p = [controller objectAtIndexPath:indexPath]; [(UILabel*) [cell viewWithTag:1] setText:p.name]; [(UILabel*) [cell viewWithTag:2] setText:@"Status"]; if(p.avatarImage){ UIImage *avatar = [[UIImage alloc] initWithData:p.avatarImage]; [(UIImageView *) [cell viewWithTag:3] setImage:avatar]; } 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.
 

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