Search display controller frame
<p>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.</p>

<p>Here is the code for searching:</p>

<h1>pragma mark UISearchDisplayController Delegate Methods</h1>

<pre><code>   - (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++;
       }
   }
</code></pre>

<p>}</p>

<pre><code> - (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]];
   }
}
</code></pre>

<p><img src="http://i.stack.imgur.com/ZaNWt.png" alt="enter image description here"></p>

<p><img src="http://i.stack.imgur.com/h4FN8.png" alt="enter image description here"></p>

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

<p>Thanks to all.</p>
