Ok, so I have a UITableViewController. In it I have dynamic tableviewcell defined. For now to make things simple lets say there are three dynamic rows defined. see screenshot

So what I am want to do is that when user touches
- row 1, I want to take them to viewcontroller1
- row 2, I want to take them to viewcontroller2
- row 3, I want to take them to viewcontroller3
Now here’s the dilemma part, when I select the prototype cell and connect it to viewcontroller1 using modal then from then onwards any row I touch it will always take me to viewcontroller1. I thought of writing this code for my UITableViewController but I don’t know how to create multiple sages? (see below)
Now it may very well be that this is a limitation of storyboard and UITableView and it cannot be done using dynamic cell. What I will have to do is create static cells and manually connect each of the rows to the corresponding view controller. I just wanted to know if there is an easier way as I got 50 rows and each row needs to be connected to a new view controller. Yes I love connecting stuff in storyboard that much. Just wanted to get a second opinion if there are any better approaches.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
//SECTION #0
if (indexPath.section == 0)
{
[self performSegueWithIdentifier:@"goto1" sender:nil];
}
//SECTION #1
if (indexPath.section == 1)
{
[self performSegueWithIdentifier:@"goto2" sender:nil];
}
//SECTION #2
if (indexPath.section == 2)
{
[self performSegueWithIdentifier:@"goto3" sender:nil];
}
}
It’s also possible to drag a segue from the yellow controller icon in the controller toolbar. Select your table view controller and a black toolbar like pictured below will show up.
Drag from the yellow icon to the desired destination controller.
This way a segue is not directly attached to a cell or anything else. Give it an identifier and you can perform it in code whenever you want.
In your case you call
performSegueWithIdentifier:sender:intableView:didSelectRowAtIndexPath:based on whatever logic you seem fit.[edit]:
50 different segues & destinations seems an awful lot. Are you sure you’re not able to reuse a single (or at least less than 50) view controller(s) (say when only the content differs?). For example you display 50 similar pages with content. Instead of creating 50 view controllers in your storyboard: create a single one and set the content of the view controller before it is shown: