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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:50:56+00:00 2026-06-02T17:50:56+00:00

i have uitableview and a search bar with searchDisplayController, i fill tableview datasource with

  • 0

i have uitableview and a search bar with searchDisplayController, i fill tableview datasource with data from database and i user search bar for searching, at a time uitableview datasource is not filtered the didSelectRowAtIndexPath works fine and it goes to the detailviewcontroller, but when i use search and filter datasource then if i select a cell the didSelectRowAtIndexPath method does not fire.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    KardexViewController* kardexViewController = [[KardexViewController alloc] initWithStyle:UITableViewStylePlain];

    [self.navigationController pushViewController:kardexViewController animated:YES];
}

this is how i add uisearchbar

- (void)viewDidLoad
{
    [super viewDidLoad];

    dataSource = [[NSMutableArray alloc] init];

    self.navigationItem.title = Title;

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];

    searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    searchDisplayController.delegate = self;
    searchDisplayController.searchResultsDataSource = self;

    self.tableView.tableHeaderView = searchBar; 
}

and how i filter datasource

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    NSMutableArray* result = [[NSMutableArray alloc] init];

    for (int i = 0; i < [self.allData count]; i++) {
        NSRange range = [[[self.allData objectAtIndex:i] valueForKey:@"Code"] rangeOfString:searchString];

        if(range.length > 0)
            [result addObject:[self.allData objectAtIndex:i]];

        range = [[[self.allData objectAtIndex:i] valueForKey:@"Name"] rangeOfString:searchString];

        if(range.length > 0)
            [result addObject:[self.allData objectAtIndex:i]];
    }

    self.dataSource  = [result copy];
    [result release];
    [self.searchDisplayController.searchResultsTableView reloadData];

    return YES;
}

-(void) searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
    self.dataSource  = [self.allData copy];
}

So Thanks inadvance

  • 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-02T17:50:57+00:00Added an answer on June 2, 2026 at 5:50 pm

    after some search i found that i just should set one thing more

    searchDisplayController.searchResultsDelegate = self;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented the search method for a UITableView populate from a NSArray (mylist):
I have a UITableView that was created from data coming from a mutable array.
I Have a search bar that searches an array, and updates a UITableView with
I have a search bar added to the navigation bar. When the user types
I have added a search bar with UITableView. when I enter the first character
i have an iOS application witch have a search bar and a UITableView. when
i have a search bar and search some information from internet, then start a
I have implemented a UITableView with search bar (and search display) - all works
I have a searchDisplayController that searches a UITableView . After entering the search terms,
I have a UITableView that has a Search Bar. Everything works fine but when

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.