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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:39:12+00:00 2026-06-16T21:39:12+00:00

I have a table view controller that implements UISearchBarDelegate and UISearchDisplayDelegate. I have a

  • 0

I have a table view controller that implements UISearchBarDelegate and UISearchDisplayDelegate. I have a button to toggle edit view for my table view. When in edit mode, a user can select many rows and copy them, delete them, etc. If I try to enter something in the search bar, while the table view is in edit mode, the shouldReloadTableForSearchString method fires, and there I re-fetch my data from core data with an updated predicate, and return YES from the function, indicating that the table view should be reloaded. When the filtered results are presented, they are not in edit mode, even though in cellForRowAtIndexPath i can see that tableView isEditing is YES. I can not see the circles for the multiple selection. I need to be able to let the user filter down their list in order to significantly constrain the results, before selecting several items.

Why are the results not showing up in edit mode?

edit mode, without using the search bar:

edit mode, without using the search bar

Searching in edit mode produces results that are not in edit mode and not styled:

Searching in edit mode produces results that are not in edit mode and not styled

Thanks in advance,
Alex

Here is the shouldReloadTableForSearchString method:

    - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
NSPredicate *predicate = nil;
if ([searchString length])
{
    NSArray* filteredTags = nil;
    if ([searchString length] < 3)
    {
        // Check for tags starting with 1 or 2 characters.
        filteredTags = [[tagResultsController fetchedObjects] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(TagEntity* te, NSDictionary *bindings)
        {
            if ([[[te.name lowercaseString] substringToIndex:[searchString length]] isEqualToString:[searchString lowercaseString]])
                return YES;

            return NO;
        }]];

    }
    else
    {
        // Check for tags with 3 or more consecutive characters anywhere in name
        filteredTags = [[tagResultsController fetchedObjects] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(TagEntity* te, NSDictionary *bindings)
        {
           if ([[te.name lowercaseString] rangeOfString:[searchString lowercaseString]].location != NSNotFound)
               return YES;

           return NO;
        }]];
    }

    //  OR ANY(self.tags) in %@
    predicate = [NSPredicate predicateWithFormat:
        @"ANY(self.songlists) in %@ AND (name contains[cd] %@ OR artist_name contains[cd] %@ OR number = %@ OR ANY(tag_entities) in %@)",
        currentSonglist.songs, searchString, searchString, searchString,filteredTags];

    [self.fetchedResultsController.fetchRequest setPredicate:predicate];

    NSError *error = nil;
    if (![[self fetchedResultsController] performFetch:&error]) {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }
    // Return YES to cause the search result table view to be reloaded.

}

return YES;

}

And here is my Core Data table view’s header from the .h file:

    @interface SonglistTVC : CoreDataTableViewController
<UISearchBarDelegate, 
UISearchDisplayDelegate,
UIPickerViewDataSource,
UIPickerViewDelegate,
UIActionSheetDelegate,
AddSongTVCDelegate,
ListSelectorDelegate>

I know it’s using my table view controller, because both cellForRowAtIndexPath and didSelectRowAtIndexPath are firing. I can debug inside and isEditing is set to YES on the table view. But yet the table view is not reflecting it’s proper edit mode styling.

Here is cellForRowAtIndexPath which fires immediately after typing a letter in the search box.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifier = @"SongCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:identifier];

Song* song = [self.fetchedResultsController objectAtIndexPath:indexPath];     

UILabel* artistLabel    = (UILabel*)[cell viewWithTag:ARTIST_NAME_TAG];
UILabel* songLabel      = (UILabel*)[cell viewWithTag:SONG_NAME_TAG];
UILabel* keyLabel       = (UILabel*)[cell viewWithTag:KEY_TAG];
UILabel* numberLabel    = (UILabel*)[cell viewWithTag:NUMBER_TAG];

//artistLabel.font = [UIFont systemFontOfSize:17];
[artistLabel setText:   song.artist_name];
[songLabel setText:     song.name];
//[songLabel setFont:[UIFont systemFontOfSize:16]];
[keyLabel setText:      song.key];
[numberLabel setText:   [NSString stringWithFormat:@"%@", song.number]];


UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,61)];
UIView *selectedBackView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,61)];

CAGradientLayer *backGradient = [[CAGradientLayer alloc] init];
backGradient.frame = cell.layer.bounds;

CAGradientLayer *selectedGradient = [[CAGradientLayer alloc] init];
selectedGradient.frame = cell.layer.bounds;

if (song.status == [NSNumber numberWithUnsignedInt: 1])
{
    [backGradient setColors:[NSArray arrayWithObjects:
                           (id)[[UIColor colorWithRed:240.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f] CGColor],
                           (id)[[UIColor colorWithRed:1 green:1 blue:1 alpha:1.0f] CGColor],
                           nil]];
}
else if (song.status == [NSNumber numberWithUnsignedInt: 2])
{
    [backGradient setColors:[NSArray arrayWithObjects:
                         (id)[[UIColor colorWithRed:240.0f/255.0f green:240.0f/255.0f blue:200.0f/255.0f alpha:1.0f] CGColor],
                         (id)[[UIColor colorWithRed:1 green:1 blue:1 alpha:1.0f] CGColor],
                         nil]];
}
else if (song.status == [NSNumber numberWithUnsignedInt: 3])
{
    [backGradient setColors:[NSArray arrayWithObjects:
                         (id)[[UIColor colorWithRed:200.0f/255.0f green:240.0f/255.0f blue:200.0f/255.0f alpha:1.0f] CGColor],
                         (id)[[UIColor colorWithRed:1 green:1 blue:1 alpha:1.0f] CGColor],
                         nil]];
}
[selectedGradient setColors:[NSArray arrayWithObjects:
                     (id)[[UIColor colorWithRed:255.0f/255.0f green:160.0f/255.0f blue:60.0f/255.0f alpha:1.0f] CGColor],
                     (id)[[UIColor colorWithRed:1 green:1 blue:1 alpha:0.7f] CGColor],
                     nil]];


if (![self.tableView isEditing] )
{
    cell.backgroundView = backView;
    [cell.backgroundView.layer insertSublayer:backGradient atIndex:1];

    cell.selectedBackgroundView = selectedBackView;
    [cell.selectedBackgroundView.layer insertSublayer:selectedGradient atIndex:1];
}
else
{
    //cell.backgroundView = backView;
    //[cell.backgroundView.layer insertSublayer:backGradient atIndex:1];
    cell.selectedBackgroundView = backView;
    [cell.selectedBackgroundView.layer insertSublayer:backGradient atIndex:1];
}

for (NSIndexPath* ip in selectedIndexes)
{
    [self.tableView selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionNone];
}

[sortOrderPicker reloadAllComponents];
[self sendPickerDownAnimated:NO];

return cell;

}

I use a button inside a segmented control to toggle editing ON/OFF:

    - (IBAction)segmentChanged:(id)sender{
UISegmentedControl* sg = (UISegmentedControl*)sender;
if (sg.selectedSegmentIndex == 0)
{
    // Edit
    if (![self.tableView isEditing])
    {
        [self.tableView setEditing:YES animated:YES];
        [self.navigationController setToolbarHidden:NO animated:YES];
    }
    else
    {
        [self.tableView setEditing:NO animated:YES];
        [self.navigationController setToolbarHidden:YES animated:YES];
        selectedIndexes = nil;
    }
    [self.tableView reloadData];
}
else
{
    // Sort
    if (pickerShown)
        [self sendPickerDownAnimated:YES];
    else
        [self bringPickerUpAnimated:YES];
}

}

  • 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-16T21:39:12+00:00Added an answer on June 16, 2026 at 9:39 pm

    The problem lies in the fact that UISearchDisplayController does so much for you automatically. It creates its own table view to present the search results, and manages that table view. You can set yourself as that table view’s data source and delegate, and by default that’s done for you automatically, but it isn’t your table view and you are not controlling it. If you want a greater hand is specifying what table view this is to be, you need to set the search display controller’s searchResultsTableView; or you can get a reference to it as thing go along (e.g. thru the UISearchDisplayController’s own delegate methods). But even so you will not be the UITableViewController that manages the results table view; that’s completely internal to UISearchDisplayController. If you don’t like that, one easy solution is: don’t use UISearchDisplayController – think of another interface.

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

Sidebar

Related Questions

I have a table view controller with (among others) a cell that is to
I have a custom view controller that implements the from UITableViewDataSource and UITableViewDelegate protocols.
I have a view controller that has a tableView in it. When I set
I want to have a ViewController that has a table view on the top
I have a Table View Controller with cells. I want to update the text
I have a table view controller with custom cells. In those cells i added
I have a table view controller which doesn't let me manually scroll to the
Using storyboard, I have a table view controller containing multiple dynamic prototype cells. One
I have view controller, into the view i have put a table view, and
I have a UITableView that gets populated from CoreData via a controller that implements

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.