2

I have a problem with a UISearchViewController (using a storyboard layout).

My main view controller has a navigation bar at the top, beneath which I have positioned the UISearchBar. A MKMapView extends below the search bar and navigation bar.

When the SearchViewController is active, the Navigation Bar slides up. I have added an autolayout constraint to stick the uisearchbar to the bottom of the nav bar. However, the search bar doesn't appear to extend beneath the status bar and above the map view. Instead the mapview appears in a 20px gap above.

Main view controller

search view controller active

Any help would be greatly appreciated!

rbaker86
  • 1,832
  • 15
  • 22
  • Duplicate question here http://stackoverflow.com/questions/19141886/uisearchbar-clipped-under-status-bar-when-added-to-uisearchdisplaycontroller/19353407#19353407 – DZenBot Oct 14 '13 at 04:10
  • @rbaker86 Did you manage to find a solution? I am struggling with this as well... – PJC Oct 24 '13 at 17:32
  • Yes. In my case: self.ibSearchBar.clipsToBounds = NO; within viewDidLoad – rbaker86 Oct 27 '13 at 19:16
  • I am struggling with this too, and clipsToBounds did not work. – runios Dec 17 '15 at 12:59

3 Answers3

1

Setting translucent to false on my navigation bar did not fix this. However setting the translucent property of my searchBar worked for me.

I used these UISearchDisplayDelegate methods to change the value depending on whether the searchBar is active or not.

func searchDisplayControllerWillBeginSearch(controller: UISearchDisplayController) {
    // self.searchBar is an IBOutlet from storyboard
    self.searchBar.translucent = false
}

func searchDisplayControllerWillEndSearch(controller: UISearchDisplayController) {
    self.searchBar.translucent = true
}
Luke Vella
  • 747
  • 1
  • 7
  • 15
0

I think it can be fixed with navigationBar.translucent = NO; It is set to YES by default in iOS 7. Had a lot of trouble with that myself.

Peter Segerblom
  • 2,773
  • 1
  • 19
  • 24
  • Thanks very much for the suggestion. I tried self.navigationController.navigationBar.translucent = NO; in the viewDidLoad method but this hasn't helped. – rbaker86 Oct 08 '13 at 19:21
0

Try this in info.plist file to disable the status bar

Try this in info.plist file to disable the status bar

vinay
  • 351
  • 1
  • 5
  • 16