I am using a UISearchDisplayController with the new ios 7 feature displaysSearchBarInNavigationBar and opaque navigation bars. The search display controller seems to position it's view incorrectly.
I tried plugging in to delegate methods and repositioning but I can not get the initial position correct, nor when rotating. In addition, this seems like a sloppy solution.
I've search endlessly online for a solution to this problem, but nothing that was recommended worked in my case. Resetting the searchResultsTable's frame didn't work because it's origin.y was already at 0. Changing the contentInset kind of worked, but didn't fix the dimmed overlay view and caused issues with the table's scroll view at the bottom (and bars). I did finally get a better working hack, although it's not completely ideal since the view's frame shifts are noticeable briefly, but at least positioning is correct after that.
Using Reveal.app, I was able to dig into the view hierarchy of UISearchDisplayController to figure out what was going on, and this was the result in my case:
I do everything programmatically, so not sure about a workaround for NIBs. Here are the basics of how my UISearchBar and UISearchDisplayController are setup in my
viewDidLoad
method:And my hack that worked in this case:
I had to add an observer for when the keyboard appears as this was causing the UISearchDisplayController to re-layout its subviews, along with a short delay to ensure my position adjustments were applied after UISearchDisplayController did it's layout stuff.
I had the same issue and I've fixed in this way:
2.In the UISearchDisplayDelegate I've added this:
1.Use Reveal, find cover layer and found to be _UISearchDisplayControllerDimmingView
2.Find the layer , modify the corresponding frame, it can be found on the map by dimmingview with searchResultsTableView sub- layer of the same view.
3.Likewise, if you need to adjust searchResultsTableView the frame, append the following code in the
Just enabled "Under Opaque Bars " in the storyboard for your view controller or if you like to code.Then add the below lines.Your good :)
I had the same issue and after hours of searching for an answer, I decided to look through the view hierarchy. It seems that the superview of the searchBar, which is also the dimmed view, has a y origin of 64 and a height of 504, which is not populating the whole screen. Not sure why it's like that. Nevertheless, I ended up setting the y to 0 and it's height to the screen height. After which, I set its y back to the original value, or else your content table view will be distorted. It's not the best solution, but it's better than nothing. Hope this helps you.