Segue Destroyer from a look-to-self controller

I am trying to create a mechanism for expanding a list of files / folders. The idea is to show the same file list view controller every time a user selects a folder, and shows a file view detailed controller if he / she selects a file.

So far, I created a segue from the file list view controller to the file view detailed view controller and segue from the file list table view cell to the file list table view controller:

enter image description here

The problem is that as soon as the user deletes the cell, segue is executed. I would like to remove segue from the table view cell and make it from the file list view controller to myself. That way, I could program the correct segue when the user tapped on the cell.

So my question is: is it possible to create a segue from a view controller in itself in Interface Builder?

+65
ios uitableview uiviewcontroller storyboard segue
Feb 10 '12 at 11:20
source share
8 answers

I developed a method for creating a segue using the phantom button. I believe this will solve your problem. You can read about it in my answer here .

+25
Feb 10 2018-12-12T00:
source share

If you are using a navigation controller, you need to push ViewController onto the navigator stack. In this example, I named my ViewController "VDI" in the setup for the storyboard identifier.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil]; YourVC *dest = [storyboard instantiateViewControllerWithIdentifier:@"VDI"]; [self.navigationController pushViewController:dest animated:YES]; 

If you do not want the NavigationController to continue adding itself to its back history, you can place the stack before adding it like that.

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil]; YourVC *dest = [storyboard instantiateViewControllerWithIdentifier:@"VDI"]; UINavigationController *navController = self.navigationController; [navController popViewControllerAnimated:NO]; [navController pushViewController:dest animated:YES]; 
+40
Apr 15 '13 at 21:12
source share

Using Xcode 5, there is a stronger solution .

  • Click a table cell in the storyboard
  • Open the connection inspector (the right arrow icon in the upper right corner)
  • In the "triggered segues" section, you see the "selection"
  • Drag from the circle next to "selection" to the cell in the storyboard

What is it.

+27
May 2 '14 at 20:16
source share

Instead of running segue on the same controller, you can create an instance of the view controller (the same) from the storyboard, and then click on the navigation controller.

+23
Jul 29 2018-12-12T00:
source share

IOS 6 has a cleaner solution than using the phantom button. You can still determine the segue from the table cell to the view controller and look at the sender to cancel the automatically generated segment:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //storyboards should use segues and override prepareForSegue instead //but here we need custom logic to determine which segue to use id item = [self.fetchedResultsController objectAtIndexPath:indexPath]; if (item meets condition) { [self performSegueWithIdentifier:@"segue1" sender:self]; } else { [self performSegueWithIdentifier:@"segue2" sender:self]; } } - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { //ignore segue from cell since we we are calling manually in didSelectRowAtIndexPath return (sender == self); } 
+13
Apr 27 '13 at 3:17
source share

Here you can click another instance of the current view controller without defining your own or hard code for your own identifier:

 SameViewController *same = [self.storyboard instantiateViewControllerWithIdentifier: self.restorationIdentifier]; [self.navigationController pushViewController: same animated: YES]; 

You just need to set the recovery identifier in the same way as the storyboard identifier (there is a checkbox for IB there).

Recovery ID

+3
Jul 19 '16 at 9:23
source share

Interface Builder approach: just go to the storyboard link that links to the view controller.

+3
Jul 26 '17 at 14:29
source share

Hope this helps.

I found that you can create multiple prototypes.

How can you associate each cell (in the storyboard) with a different view.

Something like that:

 NSString *CellIdentifier = @"Cell"; if (Condition2 ){ CellIdentifier = @"Cell2"; } if (Condition3 ){ CellIdentifier = @"Cell3"; } 
0
Sep 28 '13 at 12:55 on
source share



All Articles