Domanda

I'm looking for an answer and while I've read a lot of articles, I've not seen the obvious answers that I require.

I currently have a UITableViewController with an embedded SearchBar. The reason I need to move, or potentially move to a UISearchDisplayController is because I cannot find a way to make the searchBar permanently in place and for the TableView to scroll under it, rather than scrolling with it.

So I want to deploy a UISearchBarController and today, I realised it's simply a SearchBar from what I could see.

The question is:

I already have a working TableViewController with the SearchBar - do I have to remove the search bar and add in the searchdisplaycontroller in the interface builder?

Can I not just use the searchBar that already exists and add a property for SearchDisplayController *searchDisplayController?

Finally, am I missing something and can I make my life easier by preventing the searchBar from scrolling with the Table View, without having to use a SearchDisplayController?

I appreciate any insight into this because while everyone talks about how to implement a SearchDisplayController, not many people talk about the differences or the answers to my specific questions.

Thanks!

p.s. I'm sorry for the pretty basic question - I'm fairly new to programming and I just need to know answers to my questions above and I can then go and work on it. The ideal scenario is being able to stop the search bar from scrolling with the table view now.

È stato utile?

Soluzione

UISearchDisplayController is a convenience controller for displaying a results table and managing the search bar. If you have code already that manages the bar and displays search results, you do not need a UISearchDisplayController. Also, the search display controller will not help you with what you need (statis search bar).

What you want to achieve is possible with a search bar alone. What you want to do is have it as a subview to the view controller's view rather than the table view. That's somewhat difficult when you have a UITableViewController because the view is the table view. The simplest solution is to move to a UIViewController with a UIView base view, and a tableview as a subview of that view, as well as the static search bar. Now the bar will stay positioned as you need, with the table view below it.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top