0

The main controller is a tabBarController; one of the tabs is navigationController, then in that navigationController is a UItableView with searchDisplayController.

SearchBar is in UItableView.

enter image description here enter image description here enter image description here

However, I dont' know what I have changed (I should use snapCapture next time....). My searchBar is gone.

What I mean gone is that after my compilation, I cannot find the seaerchBar in my tab. (It is okay before I am changing sth; coz I have changed a lot, I cannot load back anymore)

I have printed a log like, [self.searchDisplayController description]

But it is NULL.

Can sbd suggest me some directions for me to check? Thanks

Ian
  • 501
  • 2
  • 10
  • 20

2 Answers2

0

In each Tab you need to add only one navigation controller, inside that you need to add either viewcontroller or tableview controller or search display viewcontroller. You need add the objects in the above way, i dont think you have added in this format, from the image you have provided, there is only one tab in that you have added 3 navigation controllers..

vishy
  • 3,241
  • 1
  • 20
  • 25
  • But in tab 1, I dont hv navigation feature. Do I need need to add navigation controller? – Ian Jan 10 '12 at 10:26
  • no, if navigation feature is not required, then no need to use navigation controller. In which tab you have search display controller or you are pushing from. – vishy Jan 10 '12 at 10:34
  • Anyway, tab1 is fine. I just don't know why my searchDisplayController is null. It should be same as Interface builder what it shows, isn't it? – Ian Jan 10 '12 at 10:46
  • Your 3rd tab is for search right? and there is no search Bar object in that view controller, add search display controller in that view controller and compile, you will find the search bar.. – vishy Jan 10 '12 at 11:14
  • In fact, it is added in ThirdViewController(see pic 2). As you can see, I actually have this in my controller and I actually reference the sample code of Apple, http://developer.apple.com/library/ios/#samplecode/TableSearch/Introduction/Intro.html – Ian Jan 10 '12 at 11:19
  • In the sample code, they have added that view controller to window. But in your code, third view controller is not relate to other view controller, you need to add search display in third view controller.. Once you do this step and let me know. – vishy Jan 10 '12 at 11:28
0

I found my fault it is.

Should be

@interface ThirdViewController : ***UIViewController*** 

NOT

@interface ThirdViewController : ***UITableViewController*** 

UIViewController Class Inherits from UIResponder : NSObject

UITableViewCell Class Inherits from UIView : UIResponder : NSObject

I think that is why for tableview, I cannot show the search bar. So, in my case, I hope can help others do not make any not necessary changes, like me @@

And please do use snapCap

Ian
  • 501
  • 2
  • 10
  • 20