segue from second view controller to first view controller ios8

203 Views Asked by At

I have 4 ViewControllers. Three of those view controllers are connected to the fourth one, which I call Photo_Detail. The segues there work fine, but now I have to make the back button go to the VC that someone came from. How can I do that? A research said to create a unwind segue in the Photo_detail, what i did but it didn't work out. That's the code I tried to use:

- (IBAction)done:(UIStoryboardSegue *)segue {
    NSLog(@"Popping back to this view controller!");
    // reset UI elements etc here
}

Thanks for any help in advance!

2

There are 2 best solutions below

3
On BEST ANSWER
- (IBAction)done:(UIStoryboardSegue *)segue {
    NSLog(@"Popping back to this view controller!");
    // reset UI elements etc here
    [self dismissViewControllerAnimated:NO completion:nil];
}

For Modal type segues, this will help you to move back.

And also select it as normal action from ViewController rather then exit. That will fix it.

Hope this helps.

0
On

If the second VC is presented modally, you simply have to dismiss the controller

    [self dismissViewControllerAnimated:NO completion:nil]: