ari gold
ari gold

Reputation: 2094

'segue' to same view controller from different table view cells

I have a tableview with five cells.

I would like each cell to segue to the same view controller, changing a property in the view controller depending on which cell was selected (didSelectRowAtIndexPath).

The main trick is that I'd like to use a storyboarded view controller for the segued to view controller.

Gratzi!

Upvotes: 1

Views: 1037

Answers (1)

Carina
Carina

Reputation: 2260

connect the view or tableview and next view controller directly by segue , but not tableview cell . And then ,

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     //set any value depending on which cell was selected
     //...
     [self performSegueWithIdentifier:@"yourSegueID" sender:self];
}  

about changing a property :

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    MyViewController *viewController = segue.destinationViewController;
    [viewController setAnyValue:anyvalue];
}

Upvotes: 1

Related Questions