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

  • Home
  • SEARCH
  • 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 4108492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:39:48+00:00 2026-05-20T21:39:48+00:00

I’m trying to set up a search display controller to handle async results from

  • 0

I’m trying to set up a search display controller to handle async results from a web service. I’ve got the basic bits in place but have run into a really strange issue that I can’t figure out.

Seems like to rig up the search display controller for async you really just need to do two things:

  1. return NO for
    searchDisplayController:shouldReloadTableForSearchString,
    and
  2. handle searchBarSearchButtonClicked
    and fire off the table reload
    myself.

I’m doing both of these but what I’m seeing is that the search display controller is reloading the table on the first character typed into the search bar even though I’m returning NO as per #1. It doesn’t reload on subsequent characters entered.

So, my question is: how do I keep the search display controller from trying to reload the table while the user is typing? (specifically on that first character entered)

I’ve seen this issue mentioned as part of a couple of other questions but I have not seen a direct answer to the problem. I’d like to understand what’s going on or what I’m doing wrong before I resort to a bunch of UI mangling to work around it.

Here’s a quick distillation of my code to show the issue. When I run this and type “abcde” into the search bar, after I type “a” the results display as “a #0”, “a #2”, etc. They don’t update again until I hit the search button then you see “abcde #0”, “abcde #1”, etc. Desired result is, of course, nothing happens until I hit the search button.

#pragma mark -
#pragma mark UISearchDisplayController Delegate Methods

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
    return NO;
}

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption {
    return NO;
}


#pragma mark -
#pragma mark UISearchBarDelegate Methods

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    [self.searchDisplayController.searchResultsTableView reloadData];

}


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = [self.searchDisplayController.searchBar.text stringByAppendingFormat:@" #%d", indexPath.row]; 
    return cell;
}

Thanks! (btw, this is my first question asked here—please let me know if I miss any points of etiquette 🙂

  • 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-20T21:39:49+00:00Added an answer on May 20, 2026 at 9:39 pm

    This is just the way UISearchDisplayController (SDC) works. When the user enters the first character into the searchBar the searchTable is loaded and displayed for the first time causing it to load. The methods “…shouldReloadTableForSearchString” and “…shouldReloadTableForSearchScope” allow you to control whether the searchTable reloads automatically on subsequent chars or a scope change.

    I’ve done both of the following to provide a good user experience on the first character. Slight disclaimer: I do have implementations of both of these that work but this is simply a framework for implementation from my memory. I may have missed a detail but this should get you pretty close.

    Option 1: Present a “loading” cell in the searchTable when the first char is typed.

    This option allows the SDC to display the searchResultsTableView when the user types the first char, display status as to the current search/filter operation

    1. in the SDC delegate class definition

      • add the iVar BOOL isLoading
      • add the iVar UITableView *searchTableView
    2. in searchDisplayController:didLoadSearchResultsTableView

      • set searchTableView = tableView
    3. in shouldReloadTableForSearchString/Scope

      • set isLoading = YES
      • call your method to load data in the background
      • return NO
    4. when your background filter is complete:

      • set isLoading = NO
      • [searchTableView reloadData]
    5. in the various tableView delegate methods respond how you like to show status if there are current search results or results are loading in the background. What I did is:

      • if there are current search results, show results (even if loading/filtering in the background)
      • if there are no search results and isLoading == NO return 1 row and show ‘No matches’ in a cell
      • if there are no search results and isLoading == YES return 1 row and and show search activity in a cell (I typically use UIActivityIndicatorView)

    Option 2: Hide the searchTableView and display an overlay view in it’s place until search results are loaded

    This option hides the searchTableView when it is first loaded and only redisplays it if when the search/filter is complete. I defined this as an add on to option 1 as they can be done together though to optimize things you may not care about showing search activity in the searchResultsTableView if you are hiding the table and showing the overlay.

    1. in the SDC delegate class definition

      • same as Option 1
      • add the iVar UIView *searchTableOverlayView
    2. in searchDisplayController:didLoadSearchResultsTableView

      • same as Option 1
      • create a UIView to use as an overlay in place of searchTableView containing whatever UI is appropriate for your app and set it to searchTableOverlayView
    3. in searchDisplayController:didUnloadSearchResultsTableView

      • release searchTableOverlayView
    4. in ‘searchDisplayController:didShowSearchResultsTableView(may be able to do this insearchDisplayController:willShowSearchResultsTableView`

      • if there are search results to display or isLoading == NO
        • seachTableOverlayView.hidden == YES
      • else (if isLoading == YES)
        • searchTableOverlayView.frame == searchResultsTableView.frame
        • add seachTableOverlayView as a subview of searchTableVIew.superview
        • searchTableView.hidden = YES
    5. when your background filter is complete

      • same as option 1
      • if there are searchResults to display
        • searchTableCoverView.hidden = YES
        • searchResultsTableView.hidden = NO
      • else
        • searchResultsTableView.hidden = YES
        • searchTableCoverView.hidden = NO
    6. in the various tableView delegate methods respond how you like to show status if there are current search results or results are loading in the background. What I did is:

      • same as option 1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to parse a xhtml file and display in UITableView. what is the
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.