IOS Unwind Segue stops working when built into the navigation controller

I have a UIViewController that has a button that executes modal segue in a UIViewController as a form sheet. On this form blank, the cancel button is canceled with the original UIViewController. This seems to work quite happily and rejects the form sheet.

Once I select the original UIViewController and select an option in Xcode to insert into the navigation controller, the unwind session no longer works and the formal formal form will no longer be canceled.

I am sure there is a simple explanation, but currently it is evading me, so any thoughts are welcome.

Thanks.

+7
source share
3 answers

I don’t know why you get the behavior you see, I see it too. This happens for both sheet sheets and sheet sheets of a form, but not for full screen. However, the unwinding segment still calls the method that you put in the original controller (the one to which you connected the unwind mode). So, all you have to do is put a string in this method:

[self dismissViewControllerAnimated:YES completion:nil]; 
+13
source

This has already been answered, but the above did not give me a complete solution, so I thought I would share it.

For me, the unwinding method was never called, so I could not do what was described above. Instead, I made a simple button with IBAction and named it. Swift example below:

 @IBAction func cancelToRecipeController() { self.dismissViewControllerAnimated(true, completion: nil) print("cancel to recipe controller ran") } 

Thanks @rdelmar above for calling the method!

(This was added for ios 9)

0
source
  self.dismissViewControllerAnimated(true, completion: nil) 

"firing" does not work for me, but popToRoot works well.

  [self.navigationController popToRootViewControllerAnimated:YES]; 
0
source

All Articles