Iphone – How to use UISearchDisplayController from a controller within an UITabBar controller

iphoneuisearchbaruisearchdisplaycontroller

I have an UITabBar controller managing several controllers (using SDK 3.0). One of these is a tableView controller and I need to provide a search capability using the UISearchDisplayController. All of my code is based on Apple TableSearch example. However, when clicking on the tab, the tableView controller appears showing its related content, but no searchBar appears. I have checked the xib in IB to make sure that all of the outlets are properly set, but no matter what I try self.searchDisplayController is always nil and the search bar does not appear.

In practice I have replicated MainView.xib from the TableSearch example and set the file's owner class to the correct controller class for the tab. The outlets are sets as in the example MainView.xib. Am i missing any important step or doing something wrong?

Thank you in advance.

Best Answer

I had the same issue and happened to stumble upon this solution ...

If you have your table view controller (eg. UISearchDisplayController) nested in a Tab Bar or Navigation controller using Interface Builder, you need to set the "Nib Name" in the "Attributes Inspector" window.

The Nib name will be the one that holds the table view and has the controller (eg. UISearchDisplayController) as the File's Owner.