I have seen this topic on here but none of the solutions clicked or worked for me. I have a UITableViewController,(call it myUITableViewController) and the requirements are such that if the user selects the one of the first three rows from myUITableViewController, they will be brought to theFirstViewController, but if they had chosen any rows above three they will be brought to theSecondViewController. I am using storyboards which do not seem to allow multiple segues off a single tableview cell. However, I can add multiple segue's directly from myUITableViewController but then I am struggling with the proper segue code and have not found a proper solution.
The best way would be to not use segues directly from IB but instead use tableview:didSelectRowAtIndexPath: and manually call them from code whenever they select a row in the table.
You should setup the segues from the tableview itself to the destinations, and not specific elements from within the table.
Something like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifierOfSegueToCall;
if (indexPath.row < 3) {
identifierOfSegueToCall = @"theFirstViewControllerSegueIdentifier";
} else {
identifierOfSegueToCall = @"theSecondViewControllerSegueIdentifier";
}
[self performSegueWithIdentifier:identifierOfSegueToCall sender:self];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With