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 8019623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:26:35+00:00 2026-06-04T21:26:35+00:00

I have a non-tableview view with a searchbar in it, and while it works

  • 0

I have a non-tableview view with a searchbar in it, and while it works perfectly, the search display controller hides the table view and overlays a dark dimmed view when an empty string is in the searchbar. I want it to show a preloaded data when the empty string is in the searchbar instead of hiding the table view and overlaying the dark dimmed view underneath the searchbar. Just like how the Google search bar in Safari for iOS works.

I found a similar question asked on stackoverflow before:
UISearchDisplayController – how to preload searchResultTableView, I couldn’t really get it to work.

I have no problem getting the preloaded data and setting the current data to it, but I’m not sure how to prevent the displaycontroller from removing the searchResultsTableView.

Thanks in advance.

  • 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-06-04T21:26:37+00:00Added an answer on June 4, 2026 at 9:26 pm

    I finally found a way to do this.

    I found out that the searchDisplayController simply removes the searchResultsTableView from the superview, so I just added the table view back into the superview whenever the display controller tried to hide the table view:

    - (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView
    {
        // add the tableview back in
        [self.view addSubview:self.searchDisplayController.searchResultsTableView];
    }
    

    and then I also have to show the tableview the first time the searchbar is clicked, so I did:

    - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
    {
        // after the data has been preloaded
        self.searchResults = self.allItems;
        [self.searchDisplayController.searchResultsTableView reloadData];
    }
    
    - (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller
    {
        [self.view addSubview:self.searchDisplayController.searchResultsTableView];
    }
    

    For me, ‘allItems’ is where I stored all the searchable items and ‘searchResults’ is where the filtered items (after the search) is stored. And of course, you would have to preload the items (e.g. search history) before reloading the data.

    I don’t know if this is a nice way or not to do it in terms of the performance and what not, but it worked perfectly for me, and I hope this could be useful for other people as well. Please comment if there is a better way to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have non-used elements on my page. In list view I can see them.
I have very custom TableView like Add Contact View in iPhone's Contacts. I like
I have a UITableView with cells. The table view shows a list of downloaded
Under what circumstances will a CGBitmapContext fail to allocate? I have a table view,
I have non blocking UDP socket in perl created this way my $my_sock =
I have non-sass: .rounded-corners { -moz-border-radius-topleft: 4px; and want to do something like: $radius_size:
I have non-ascii chars in velocity template files. And when processed they are garbled.
I have non-template class with a templatized constructor. This code compiles for me. But
In one of the projects I have non-English content (Finnish) available on form data.
I have two non-negative longs. They may be large, close to Long.MAX_VALUE. I want

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.