Search code examples
iossearchbarsearchdisplaycontroller

searchDisplayController description is null?


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


Solution

  • 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