1

My program does not have an explicit table. It’s only table comes from “Search Bar and Search Display Controller” view as searchDisplayController.searchResultsTableView. So to create it’s custom TableViewCell, I use a xib file. Now I need to segue from the custom cell defined in the xib file to a ViewController defined in the storyboard? How do I do that?

stated differently: How to segue from a custom TableViewCell of “searchDisplayController.searchResultsTableView” to a ViewController

back story How do I add storyboard-based Header and CustomTableCell to a “Search Bar and Search Display Controller”

There seems to be an answer already but I don't get it: Segue from Storyboard to XIB

Community
  • 1
  • 1
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199

2 Answers2

0

As we discussed in comments above, it's better to avoid UISearchDisplayController since it's deprecated in iOS 8.

So it would be better to use something like that https://github.com/alexbutenko/SimpleUITableViewSearch

You can use self.navigationItem.titleView = searchBar to embed search bar into navigation bar. If you have any issue just check code sample.

Alex
  • 378
  • 1
  • 14
  • Do you mind breaking it down a bit? I already read the following answer and didn't get it: http://stackoverflow.com/questions/18401825/segue-from-storyboard-to-xib – Katedral Pillon Jul 21 '14 at 23:39
0

As with any table view, you should be able to set the UITableViewDelegate and UITableViewDatasource delegates on the searchDisplayControl class. And then handle segue event in the didSelectRowAtIndexPath method. I've never played with search display controllers as I typically break apart search bar and table views when I do anything search related for the sake of flexibility, and how you're saying you want to use prototype table view cells in a tableview within the storyboard.

But, if you're set on using the searchDisplayController, you could possibly get away with something like this..

You can't segue from one XIB -> Storyboard, or between 2 different storyboards.

You can pass a reference to the viewController to each tableViewCell, and access the segue that way if you'd like. However, I'd probably use protocols/delegates personally in this situation for the sake of future flexibility.

Braydon Batungbacal
  • 1,028
  • 2
  • 24
  • 52
  • **This is an aside:** You say you always keep SearchBar and Table separate. I tried that but it was not working when the data source is the server? So if you have a git project or some sample code you don't mind sharing, PLEASE: I am learning iOS at this phase and I would love to know how I might do the following: User uses searchBar to launch search on server and when server response arrives the data is displayed through the table. (Sorry I digressed but it sounds like you might know iOS quite a bit better than I do). – Katedral Pillon Jul 21 '14 at 23:32
  • Also another problem with that approach was having the searchBar appear in the NavigationBar – Katedral Pillon Jul 21 '14 at 23:34
  • Also please note that UISearchDisplayController is deprecated in iOS 8, so it would be better to avoid it by now. – Alex Jul 22 '14 at 00:29
  • https://github.com/alexbutenko/SimpleUITableViewSearch Check this project for sample. Feel free to ask any questions – Alex Jul 22 '14 at 00:58
  • I am playing around with it -- so far so good. But the problem of putting the search bar inside the Navigation bar still persists. Do you have some ideas on how to do that? – Katedral Pillon Jul 22 '14 at 01:55
  • I embedded initial viewcontroller into navigation controller and there is no issue with appearance of searchBar into navigationBar. It's below as expected. You can check that. – Alex Jul 22 '14 at 02:24
  • for the embedding check here: http://stackoverflow.com/questions/3351464/how-to-add-search-bar-in-navigation-bar-for-iphone – Katedral Pillon Jul 22 '14 at 08:38
  • Got it, updated code, just few lines. Updated my answer. If you have any questions comment there, please. – Alex Jul 22 '14 at 10:54