1

I have found a lot of solutions to avoid this problem, sadly none of them has worked for me. Here is the screenshot of the issue when I click the searchBar.It pushes up the navigation controller also as you can see. enter image description here

Now here is what I have tried.

Solution 1:

if([self respondsToSelector:@selector(setEdgesForExtendedLayout:)])
{
    self.edgesForExtendedLayout = UIRectEdgeNone;

}

Sloution 2:

-(void)viewDidAppear:(BOOL)animated{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
    CGRect statusBarFrame =  [[UIApplication sharedApplication] statusBarFrame];
    [self.cityTableView setFrame:CGRectMake(self.cityTableView.frame.origin.x, self.cityTableView.frame.origin.y+statusBarFrame.size.height, self.cityTableView.frame.size.width, self.cityTableView.frame.size.height)];

   }
}

Solution 3:

 - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
if (IS_OS_7_OR_LATER) {
    CGRect statusBarFrame =  [[UIApplication sharedApplication] statusBarFrame];
    CGRect frame = self.citySearchBar.frame;
    frame.origin.y += statusBarFrame.size.height;
    self.citySearchBar.frame = frame;
}
}

- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller {
if (IS_OS_7_OR_LATER) {
    CGRect statusBarFrame =  [[UIApplication sharedApplication] statusBarFrame];
    CGRect frame = self.citySearchBar.frame;
    frame.origin.y -= statusBarFrame.size.height;
    self.citySearchBar.frame = frame;
}
}

Solution 4:

 - (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller {
self.navigationController.navigationBar.translucent = YES;
 }

 - (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {
self.navigationController.navigationBar.translucent = NO;
 }

Solution 5: May be useful in case of Autolayout.But I am not using it.

 - (void) viewDidLayoutSubviews
 {
    if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
   {
      CGRect viewBounds = self.view.bounds;
      CGFloat topBarOffset = self.topLayoutGuide.length;
      viewBounds.origin.y = topBarOffset * -1;
      self.view.bounds = viewBounds;
   }
 }

So what am I missing here?

iCodes
  • 1,382
  • 3
  • 21
  • 47
  • 1
    A simple google search. I think it is the same problem. Link: http://stackoverflow.com/questions/2813118/prevent-a-uisearchdisplaycontroller-from-hiding-the-navigation-bar – antonio Jul 30 '14 at 13:54

0 Answers0