Unwind Segue for UINavigationController

I have a simple UINavigationController which pushes a UIViewController onto the stack via a custom segue. I then implemented an IBAction on the first UIViewController to perform an unwind action and I implement segueForUnwindingToViewController. Unfortunately, the segueForUnwindingToViewController is not being called (I did confirm that canPerformUnwindSegue is being called on the first VC).

I have not seen any simple examples of this behavior. Can anyone please help? Thanks.

  • Include pods in main target and not in WatchKit extension
  • How to convert a MTLTexture to CVpixelBuffer to write into an AVAssetWriter?
  • Navigation bar is moving up to statusbar
  • How can I underline text in iOS 6?
  • UILabel appear in debug view hierarchy but not in the application
  • iPhone 4" screen with xcassets not pulling correct image
  • Here’s the code from the root view controller of the NavigationController.

    - (IBAction) unwindFromSegue:(UIStoryboardSegue *)segue {
    // unwinds back to here
    //[self performSegueWithIdentifier:@"UnwindToObjectManageSegue" sender:self];
    
    }
    
    - (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController
                         withSender:(id)sender {
    return YES;
    }
    
    - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
    return YES;
    }
    
    - (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController
                                      fromViewController:(UIViewController *)fromViewController
                                              identifier:(NSString *)identifier {
    ObjectManageObjectDetailSegue *segue = [[ObjectManageObjectDetailSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
    [segue setUnwinding:YES];
    return segue;
    }
    

    Solutions Collect From Internet About “Unwind Segue for UINavigationController”

    I had the same problem and I finally found a solution:
    https://github.com/simonmaddox/CustomUnwindSegue

    He also had a problem with it not being called. Turns out that any view controller that is in a UINavigationController will not call the presenting view controller but the UINavigationController instead. This means you must subclass that UINavigationController and add that method there instead.