Search code examples
objective-cuisearchdisplaycontroller

Prevents UISearchDisplayController from hiding the UiTable


Im new to objC and Im currently experimenting on UISearchDisplayController. Basically I have an array of string as my data and I use UISearchBarDisplayController to filter my data. Im able to retrieve the correct values when I enter my searchText into the search bar. However, the tableView disappears when my searhBar text is empty.

Would it be possible to prevent the tableView from hiding in this such case. What I want is to just to display all the values in my array in the table if the searchBar text is empty.

I checked the hidden/alpha/frame property of the table and tried to fix my issue here but I think Im in the wrong path here. I'm thinking if i need to subclass the UISearchDisplayController and override the [setActive:YES animated:YES];? Any hint would be appreciated.


Solution

  • I ended up working with UISearchBar and UITable. So here are the scenarios I encountered.

    1. Display the the UITable when the searchBar is clicked.
    2. UITable shows all the data from my plist when searchText is empty.
    3. UITable shows filtered results from my plist that matches the searchText.
    4. Dismiss the keyboard on press of the search button but don't disable the cancel button on the searchBar.
    5. Remove the UITable when cancel button is press.

    I don't have the animation for showing the table for now but this works for me. Also, I allowed the user interaction and scrolling on my table during search so no overlay needed in this case. Glad its working now. :)

    I created a sample project for those who might need. Here is the link. Apologies for a messy code and leaks issues. Just posted this to share. :)