Jim Jeffers
Jim Jeffers

Reputation: 17930

UISearchDisplayController Results Table Overlapping UISearchBar

I'm having a strange issue with my UISearchDisplayController. When the search display activates the frame of the background fading view and the tableview are incorrectly overlapping the UISearchBar. It appears the results tableview is not taking the offset for the UIStatusBar into account.

The ViewController is using auto layout. Since the application does not use any opaque bars, the view controller does not extend any of its edges.

 Extend edges under top bars = NO, 
 under bottom bars = NO, and
 under opaque bars = NO.

Here is the initial layout:

Initial Layout

This is what happens when the search display activates:

Activated Search

And finally, here is the resulting output of the search:

Search Results

Upvotes: 0

Views: 2272

Answers (1)

Jim Jeffers
Jim Jeffers

Reputation: 17930

I solved my own problem. A hard lesson learned. After a few hours of thinking "It really shouldn't be this hard." I realized that my instance of UISearchDisplayController was not properly linked to the API provided property of its parent view controller. If you're using UIStoryBoards / Interface Builder be sure to click on your ViewController and view its provided outlets in the inspector. If you see this:

Missing Outlet

Then something is wrong and you're going to run into issues just as I had. What you'll want to do is to click in that empty circle and drag to your instance of the Search Display Controller. If things are linked up right you should see this:

Correct Link

I foolishly didn't pay attention to this and created my own IBOutlet to reference the Search Display controller. That caused IB to null out the API provided outlet as a UIViewController can only support one Search Display Controller. If you need me to clarify anything let me know.

Upvotes: 3

Related Questions