Hi I have a storyboard and I can show a detailed view when I click on a table cell. I want to add additional functionality so that depending on which cell I click, I show a different view controller. I tried to drag two segments from one cell, but this does not allow.
My thinking was that I would have two segue from the cell, each of which would point to a different view, and then call the desired segment:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = indexPath.row; NSLog(@"Selected Item :-) %@",[NSString stringWithFormat:@"%@",[myData objectAtIndex:row]]); if(row %2 ==0){ NSLog(@"Even"); [self performSegueWithIdentifier:@"ShowSecondIndex" sender:self]; }else{ [self performSegueWithIdentifier:@"ShowSelectedMovie" sender:self]; NSLog(@"Odd"); } }
Then I processed segue in prepareForSegue file
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSLog(@"Prepare For Segue ID:%@",[segue identifier]); if([[segue identifier] isEqualToString:@"ShowSelectedMovie"]){ Tab2_ItemViewController *vc = [segue destinationViewController]; NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row]; NSLog(@"Selected Index: %d",selectedIndex); [vc setSelectedItem: [NSString stringWithFormat:@"%@",[myData objectAtIndex:selectedIndex]]]; NSLog(@"String Value: %@",[NSString stringWithFormat:@"%@",[myData objectAtIndex:selectedIndex]]); [vc setSelectedIndex:selectedIndex]; }else if([[segue identifier] isEqualToString:@"ShowSecondIndex"]){ NSLog(@"Viewing Second Index"); } }
However, he never shows the second performance. This is because it is impossible to have two segments from the same table cell. I also tried dragging as segue from the controller to each destination, not from the cell, and the other from the controller, but failed ???
ios storyboard segue
Bear Jan 12 2018-12-12T00: 00Z
source share