Search code examples
objective-cuitableviewuisearchbardetailview

UISearchBar and segues


Im using UITableViewController to manage data. When I click on the cell my program goes to another scene (let it be myDetailViewController). But i just added search bar (UISearchViewController) and search works great but when I click on the cell from the table with the filtered data nothing happens. But I need the program to go to myDetailViewController scene to view object details. How can i perform it?

Btw, for changing views (from a basic cells, not filtered) I'm using segues. And I'm also using this method:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"nameofmysegue"]) {
//some code to give some data to new controller;
    }
}

And when I'm using tableView:didSelectRowAtIndexPath: without segues nothing happens at all.


Solution

  • Make sure to connect the segue to the view controller itself and not the tableview row. Then in your didSelectRowAtIndexPath, you do a [self performSegueWithIdentifier@"mySegueID"];