Why it doesn't show the contents of the cells in a UITableView filtered by a uisearchdisplaycontroller. In practice when I execute the search in the Searchbar, the cells are decoded correctly (in fact the number of cells sorted by the search is exact) but also configuring them in cellForRowAtIndexPath cell content is not shown (image and text). In addition, if I click on one of the cells searched, the exact way in prepareForSegue performs the transition to the corresponding viewController. So the problem is just that it doesn't show text and image in my cell.
Considering that the array configuration (array searchResults) is correct, I show you my method cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
cell.backgroundView = [[UIImageView alloc] initWithImage:myImage];
if ( cell == nil ) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
if (tableView == self.searchDisplayController.searchResultsTableView) {
UIImage *profileSnap = myProfImage;
NSString *name = [searchResults objectAtIndex:indexPath.row];
UILabel *cellLabelName = (UILabel *)[cell viewWithTag:1];
cellLabelName.text = name;
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:2];
[cellImage setImage:profileSnap];
}
else{
//here it all works
UIImage *profileSnap = [self.arrProfileSnaps objectAtIndex:indexPath.row];
NSString *name = [self.arrNames objectAtIndex:indexPath.row];
UILabel *cellLabelName = (UILabel *)[cell viewWithTag:1];
cellLabelName.text = name;
UIImageView *cellImage = (UIImageView*)[cell viewWithTag:2];
[cellImage setImage:profileSnap];
}
return cell;