How to dismiss a TableViewController within code called by a storyboard push segue?

I know how to handle push segues in Storyboard and the use of the back button that is created with the navigation controller. I have one main tableview connected to a child tableview via push segue in Storyboard. Works fine for switching between tables.

I want to add the ability to also gesture swipe left in the child tableview to return to main tableview.

First tried this within Storyboard with the use of the swipe gesture recognizer, but this caused the main tableview to become a new child to the child tableview.

I then tried within code:

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

... but this seems to only work with a modal segue

I have:

- (void)viewDidLoad
{
   [super viewDidLoad];

   UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
   [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
   [self.tableView addGestureRecognizer:recognizer]; 
}

- (void)handleSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
   // need code here to dismiss the child tableview
}

Answers


Finally figured it out today and it works perfectly:

- (void)handleSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
    [self.navigationController popViewControllerAnimated:YES];
}

Found answer in:

iOS Developer Library > UINavigationController Class Reference > popToViewController


Need Your Help

Sorted Hadoop WordCount Java

java sorting hadoop mapreduce bigdata

I am running the WordCount program of Hadoop in Java and my first job (getting all the words and their count) works fine.