Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Unwind Segue stops working when embedded in a navigation controller

I have a UIViewController which has a button that performs a modal segue to a UIViewController as a Form Sheet. On that form sheet is a cancel button with an unwind segue back to the original UIViewController. This seems to work perfectly happily and dismisses the form sheet.

As soon as I select the original UIViewController and select the option in XCode to Embed in a Navigation Controller, the unwind segue no longer seems to work and the modal form sheet will no longer cancel.

I'm sure there is a simple explanation, but it is currently evading me, so any thoughts welcomed.

Thanks.

like image 363
Darren Avatar asked Apr 07 '13 10:04

Darren


1 Answers

I don't know why you get the behavior you're seeing, I see it too. It happens for both the page sheet and form sheet presentations, but not for full screen. However, the unwind segue is still calling the method you put in the original controller (the one you connected the unwind segue to). So, all you need to do is put a line in that method:

[self dismissViewControllerAnimated:YES completion:nil];
like image 51
rdelmar Avatar answered Oct 20 '22 00:10

rdelmar