0
votes

I have four view controllers:

  • VC1
  • VC2 that contains a childViewController (VC3)
  • VC4

This is the workflow:

  1. VC1 shows (push) VC2, loading also VC3.
  2. a. It is possible to go back to VC1 with an unwind segue that it is working fine.
  3. b. VC3 has some buttons that shows (push) VC4.
  4. VC4 has a selectable list.

I want to go back with selected row to VC1, so I have implemented an unwind method to return from VC4 to VC2, and then, inside unwindToVC2 method, I am calling another segue:

[self performSegueWithIdentifier:@"returnToVC1"];

But this segue is not being called or it is not working.

Trying to debug the problem, the app goes back perfectly to VC2, and it calls the "returnToVC1" segue but nothing ocurrs, and it doesn't throw any error.

Searching for a fix, I have found that unwind method is called before the presented view has disappear. Is it the cause of the problem? is it not possible to unwind VC2 because VC4 is still visible?

Is there any way to go back two View Controllers sending info?

Thank you

1
Why don't you have the segue (from VC4) go directly back to VC1?rdelmar
Yes, thank you! I though it was not possible (like Android), because VC2 was in the middle of the stackvictor.alm

1 Answers

0
votes

As @rdelmar said, the only thing I have to do is an unwind segue to VC1. I came from Android and I though it was not possible because VC2 was in the middle of the others VC in the stack.

Another solution, not working as fine as the first is to perform the VC2 unwind segue in viewDidAppear, instead of unwind method. This fix works but it shows the second view controller for a while.

The reason of the problem is that performSegue cannot be called when the ViewController which execute it is not visible.

Thanks @rdelmar