Adding segue from UITableView search results

So I have a UITableView filled with questions. The cells in this table are related segue to another view that contains the answer to the question. This segue has the identifier 'showAnswer'. Now I want to implement the search function in the question table, and I want each cell in the results to also go on to view the answers.

So, in the controller checklist there is code to add the search string and its controller (this is in Swift, by the way, but the logic is the same):

    let resultsController = SearchResultsController()
    resultsController.questions = questions
    searchController = UISearchController(searchResultsController: resultsController)

    let searchBar = searchController.searchBar
    searchBar.placeholder = "Enter a search term..."
    searchBar.sizeToFit()
    questionTable.tableHeaderView = searchBar
    searchController.searchResultsUpdater = resultsController

Now in the SearchResultsController, after selecting the row, I want to move on to viewing the answers. Here is what I got:

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
                performSegueWithIdentifier("showAnswer", sender: self)
            }

, , " SearchResultsController " showAnswer ". , ? SearchResultsController , , ctrl + , segue SearchResultsController AnswersController. , ?

+4
1

segue .

segue, , , .

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    YourViewController.performSegueWithIdentifier("showAnswer", sender: questions[indexPath.row])
        }
0

All Articles