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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:56:13+00:00 2026-05-31T14:56:13+00:00

I am using search display controller in my code for searching. But it is

  • 0

I am using search display controller in my code for searching. But it is giving some problem. When view is load search bar frame is going out of the view but whenever I am trying to search something it comes in its proper frame which I need. I am unable to recognize the problem in my code. I have attached the images which will make you more clear about the problem.

Here is the code for searching:

pragma mark UISearchDisplayController Delegate Methods

   - (void)handleSearchForTerm:(NSString *)searchTerm
    {
   searchbar.frame = CGRectMake(391, 28, 586, 44);
 [self setSavedSearchTerm:searchTerm];

if ([self searchResults] == nil)
{
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [self setSearchResults:array];
}

[[self searchResults] removeAllObjects];

if ([[self savedSearchTerm] length] != 0)
{
    int i = 0;
    
    for (NSString *currentString in [[self contentsList]valueForKey:@"name"])
    {
        if ([currentString rangeOfString:searchTerm options:NSCaseInsensitiveSearch].location != NSNotFound)
        {
            [[self searchResults] addObject:currentString];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"id"]];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"category"]];
            NSString *searchcategory = [[[self contentsList]objectAtIndex:i] objectForKey:@"category"];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"flavour"]];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"price"]];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"image"]];
          }
        i++;
       }
   }

}

 - (BOOL)searchDisplayController:(UISearchDisplayController *)controller 
 shouldReloadTableForSearchString:(NSString *)searchString
{
searchbar.frame = CGRectMake(391, 28, 586, 44); 
[self handleSearchForTerm:searchString];
return YES;
}

- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
{
searchbar.frame = CGRectMake(391, 28, 586, 44);
[self setSearchResults:nil];
[self setSavedSearchTerm:nil];
[[self itemstable_ipad]reloadData];
}

-(void)searchmethod
{
searchbar.frame = CGRectMake(391, 28, 586, 44);
[self setContentsList:categoryarray_ipad];
if ([self savedSearchTerm])
   {
    [[[self searchDisplayController] searchBar] setText:[self savedSearchTerm]];
   }
}

enter image description here

enter image description here

please if anyone has idea how to set search bar frame, provide me some solution.

Thanks to all.

  • 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-31T14:56:15+00:00Added an answer on May 31, 2026 at 2:56 pm

    Thanks for viewing my problem. I have resolved this problem by using searchbar programmatically instead of search display controller.

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

Sidebar

Related Questions

In my web application, I display the search results using XSLT. There are some
On my iPhone app I'm using a UISearchBar (without a Search Display Controller). I
I require help to search a text file (log file) using c# and display
I'm using Zend_Search_Lucene, the PHP port of Java Lucene. I currently have some code
I'm using the search filter (objectClass=user) to find user objects, but of course it
I've been using the search function but I think there isn't any related question
I am using Sphinx Search . It's working fine for me except one problem:
I am having an odd problem when searching a UITableView using a UISearchDisplayController. The
I have a problem with search box. So here is the code to generate
My tableview is in this user interface: But when I start search the view

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.