У меня есть viewcontroller с наконечником - у которого есть панель просмотра, searchbar и searchdisplaycontroller внутри.tableView: cellForRowAtIndexPath: не получается вызываться при использовании поисковой панели
Контроллер содержимого searchdisplaycontroller, делегат результатов, делегат и источник данных результатов подключены к диспетчеру просмотра в IB. Делегат панели поиска подключается к контроллеру представления в IB. Основной вид таблицы также подключен к контроллеру view и его загружаемым элементам во время выполнения.
Все, кажется, работает, за исключением resultstableview - оно никогда не заполняется, а tableView: cellForRowAtIndexPath: никогда не вызывается ПОСЛЕ того, как пользователь вводит в поисковую панель - он получает вызов только для заполнения основного вида таблицы.
- (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;
}