简体   繁体   中英

Tableview to itself and to Viewcontroller [Multiple segues]

I have a UITableView with many cells and depends on the cell's content it suppused to go to the same UITableView with new cells or to a UIViewController . I can do this but not at the same time, is it possible to do it?

I thought in a prepareForSegue method like this one:

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
      NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

     if ([[segue identifier] isEqualToString:@"NextLevel"]) {
         [segue.destinationViewController setActualNodo:[actualNodo getSonAtIndex:indexPath.row]];
     } else if ([[segue identifier] isEqualToString:@"Service"]) {
         [segue.destinationViewController setServiceName: whatever]
     }

 }

The problem is in the Storyboard that I can't ctrl+drag two segues from the same cell. Thanks.

No, that's not possible for segues in IB. You can check for different segues that all originate from your controller the way you show in prepareForSegue, but a UI element can only have one segue connected to it.

To do what you want, you should make a segue from the table view controller itself to the new controller. Then, in didSelectRowAtIndexPath , use whatever logic you want to decide whether to go to this new controller (with [self performSegueWithIdentifier:sender:] ), or to update the table view with new cells.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM