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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:02:21+00:00 2026-06-05T02:02:21+00:00

I have implemented searchbar and searching text in table view . The problem I

  • 0

I have implemented searchbar and searching text in table view . The problem I m getting is that when I scrolls the table view and then suddenly click on search bar causes app to quit.

have any body idea how can we do anything to stop scroll when click on search bar.

My code is as follows:

    - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
 NSLog(@"becomes first responder");
 [table setScrollEnabled:NO];
 return YES;
}// return NO to not become first responder

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
 isSearchOn=YES;
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
 searchBar.text=@"";
 isSearchOn=NO;
 [searchBar resignFirstResponder];
 [table setScrollEnabled:YES];
}

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
 if ([searchText length]>0) 
  isSearchOn=YES;
 else
  isSearchOn=NO;

 NSLog(@"search text %@",searchText);
 [self searchText:searchText];
 [table reloadData];
}

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
 NSLog(@"end editing called.....");
 searchBar.text=@"";
 [table setScrollEnabled:YES];
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
 [searchBar resignFirstResponder];
}



    -(void)searchText:(NSString*)str
{
 NSLog(@"search text");
 [resultArray removeAllObjects];


 if (segmentControl.selectedSegmentIndex==0) {
  for (NSDictionary *CellDix in FriendSuggestion) 
  {
   NSRange titleResultRange =  [[CellDix valueForKey:@"itemid.item"] rangeOfString:str options: (NSCaseInsensitiveSearch | NSLiteralSearch)];

   NSRange titleRangePopular=[[CellDix valueForKey:@"usagecategoryid.usagecategory"] rangeOfString:str options:(NSCaseInsensitiveSearch | NSLiteralSearch)];

   if (titleResultRange.length > 0 || titleRangePopular.length>0)
    [resultArray addObject:CellDix];
  }
 }else
 {
  for (NSDictionary *CellDix in popularSuggestion) 
  {
   NSRange titleResultRange =  [[CellDix valueForKey:@"itemid.item"] rangeOfString:str options: (NSCaseInsensitiveSearch | NSLiteralSearch)];

   NSRange titleRangePopular=[[CellDix valueForKey:@"usagecategoryid.usagecategory"] rangeOfString:str options:(NSCaseInsensitiveSearch | NSLiteralSearch)];

   if (titleResultRange.length > 0 || titleRangePopular.length>0)
    [resultArray addObject:CellDix];
  }
 }
  • 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-05T02:02:23+00:00Added an answer on June 5, 2026 at 2:02 am

    Clicking on search bar will on isSearch bool variable and as U would have applied condition in cellforRowAtIndexpath will call and it checks for isSearch on then it works accordingly and result array will be empty there because U have not written any thing on search bar that is to be checked and load and resultArray with values . That’s why it is quiting the app because it founds null array in cellforRowAtIndexpath to fill cell values.So better one is that u have to on isSearch on textDidChange in searchbar not in searchBarTextDidBeginEditing delegate method . So comment this method.

      - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
        {
         isSearchOn=YES;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a SearchBar using an UIViewController, UISearchBarDelegate, UISearchDisplayDelegate, and when the search
I have implemented an autocomplete / instant search on a mobile application that I
I have a UI table view with a search bar and it works well
I have implemented a table view with multiple threads. Currently when a user taps
I have implemented one application in android which uses epublib to view .epub files.
I have implemented Solr search in one of my .net application. Everything working fine
I have implemented a simple D3.js line chart that can be zoomed and panned.
I am having a problem in searching a ListView. In my activity I have
I have implemented the search bar in my app and it´s working fine, but
I get this error when i play with the searchbar that I have just

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.