Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3343728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:59:17+00:00 2026-05-18T00:59:17+00:00

I have a viewcontroller with a nib – which has a tableview, searchbar and

  • 0

I have a viewcontroller with a nib – which has a tableview, searchbar and searchdisplaycontroller inside.

The searchdisplaycontroller’s contentscontroller, results delegate, delegate and results datasource is wired to the viewcontroller in IB. The searchbar’s delegate is wired to the view controller in IB. The main tableview is also wired to the viewcontroller and its loading items during runtime properly.

Everything seems to work except the resultstableview – it never gets populated and the tableView:cellForRowAtIndexPath: never gets called AFTER the user types into the searchbar – it only gets called to populate the main tableview.

- (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;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:59:18+00:00Added an answer on May 18, 2026 at 12:59 am

    Fixed it – it was returning 0 here:

     - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
        {
            if (tableView == self.searchDisplayController.searchResultsTableView)
            {
                return [self.filteredListContent count];
            }
            else if (tableView.tag == 1)
            {
                return [self.listContent count];
            }
            else if (tableView.tag == 2)
            {
                // Return the number of rows in the section.
                return [[self hotelList] count];
            }
    
            NSLog(@"The rows in tableview!");
            return 0;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ViewController that has its own NIB. I would like to embed
I have a ViewController with a nib which have a UIView and a UITableView
I have a ViewController with a nib file and want to delegate code that
Does anyone have any tips for this scenario. My app delegate's nib has a
I have a ViewController embedded in a NavigationController. The ViewController has a UIWebView that
I have an app which has a UINavigationController, which has a couple of UIViewControllers.
I have presented the viewController which contains a navigation controller whose view is loaded
I have an iOS application for which I want to create a ViewController programmatically.
I have a UITableView which loads through it's navigationController a new viewcontroller. This code
I have a ViewController in Interface Builder that has a TableViewController embedded in it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.