1
votes

In Xcode, when I try to connect a view controller with a segue, I get a choice of fire the segue upon selection of the table cell or from the cell's accessory. How do I create the segue to fire from the cell's editing accessory (which isn't visible on the storyboard)?

1
Hook the segue from view controller to destination controller. And call performSegueWithIdentifier:sender: manually when you need it. - Desdenova

1 Answers

0
votes

Add accessoryButtonTappedForRowWithIndexPath Delegate method of tableview and than add segue code in that delegate method.

// Tap on row accessory
    - (void) tableView: (UITableView *) tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *) indexPath{
           [self performSegueWithIdentifier:"MyVC" sender:self];
    }

And if you are using navigationcontroller than

// Tap on row accessory
    - (void) tableView: (UITableView *) tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *) indexPath{
           ViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyVC"];
           [[self navigationController] pushViewController:vc animated:YES];
    }

This methods called when you tap on accessory button but if you want this on row tapped than use didSelectRowAtIndexPath Method