J'ai un viewcontroller avec une plume - qui a une tableview, searchbar et searchdisplaycontroller à l'intérieur.tableView: cellForRowAtIndexPath: ne pas être appelé lors de l'utilisation de la barre de recherche
Le contrôleur de contenu de searchdisplaycontroller, le délégué de résultats, le délégué et la source de données de résultats sont câblés au contrôleur de vue dans IB. Le délégué de la barre de recherche est connecté au contrôleur de vue dans IB. La tableview principale est également câblée au viewcontroller et ses éléments de chargement pendant l'exécution correctement. Tout semble fonctionner à l'exception de resultstableview: il n'est jamais peuplé et la tableView: cellForRowAtIndexPath: ne reçoit jamais d'appel APRÈS que l'utilisateur tape dans la barre de recherche - il est seulement appelé pour remplir la tableview principale.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
// Dequeue or create a cell o f the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if (tableView.tag == 2)
{
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
// Configure the cell.
NSHotel *selectedHotel = [[self hotelList] objectAtIndex:[indexPath row]];
//Store the hotel id for use later
selectedHotel.id = [indexPath row];
//cell.textLabel.text = [NSString stringWithFormat:@"Catalonia Majorica", indexPath.row];
cell.textLabel.text = [selectedHotel name];
}
else if (tableView.tag == 1)
{
cell.accessoryType = UITableViewCellAccessoryNone;
// Configure the cell...
NSAirport *selectedAirport = nil;
if (tableView == self.searchDisplayController.searchResultsTableView)
{
selectedAirport = [self.filteredListContent objectAtIndex:indexPath.row];
}
else
{
selectedAirport = [self.listContent objectAtIndex:indexPath.row];
}
//Set the label of the cell formatting the distance from the device
cell.textLabel.text = [NSString stringWithFormat:@"%@ - %@ miles",
selectedAirport.name, [self formattedStringWithDecimal:selectedAirport.milesFromDevice]];
//Adjust the front of the label
cell.textLabel.font = [UIFont boldSystemFontOfSize:12];
}
return cell;
}