rob-brown / RBStoryboardLink

Makes transitioning between storyboards possible.
Other
840 stars 110 forks source link

Unwind does not work #28

Open xissburg opened 10 years ago

xissburg commented 10 years ago

It looks like unwind segues don't work with the new workflow. Since the destination is changed in -[RBStoryboardSegue initWithIdentifier:source:destination:] I get a 'Receiver (<UINavigationController: 0x109444040>) has no segue with identifier '<SegueName>' kind of error. If I modify the code to not change the destination view controller and perform the unwind segue on the RBStoryboardLink instance it works as expected. Also, the methods after the comment The following methods are important to get unwind segues to work properly. in RBStoryboardLink.m are never called.

oottinger commented 10 years ago

I too am having problems with unwinding. @xissburg can you provide the code you used to make this work? I tried your suggestion and had no luck. I'm not sure if it's because I'm doing this in swift or not.

xissburg commented 10 years ago

@oottinger https://github.com/xissburg/RBStoryboardLink/commit/45e8ebad1b35dbc9cdc8fbc46145508f3a2f36ed

rob-brown commented 10 years ago

I would like to see a sample project of how to exploit this issue. The code fix shown just appears to disable view controller redirection, which eliminates the purpose of RBStoryboardSegue.

xissburg commented 10 years ago

That disables the mechanism that gets RBStoryboardLink out of the view controllers stack. Hence, in my prepareForSegue:sender: I have to do something like this:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"DumbSegue"]) {
        __weak RBStoryboardLink *storyboardLink = segue.destinationViewController;
        UINavigationController *navigationController = (UINavigationController *)storyboardLink.scene;
        RSDumbViewController *dumbViewController = navigationController.viewControllers[0];
        // Configure view controller...
    }
}
ghost commented 10 years ago

Any fix for this?? Our unwinds are broken in iOS 8 also.

rob-brown commented 10 years ago

I don't have a sample project exploiting this issue yet, and I don't have time to explore this issue on my own right now.

exhaze commented 10 years ago

I noticed I was getting some console messages associated with this issue:

Presenting view controllers on detached view controllers is discouraged

It seems that if you perform a segue inside of a UIViewController that's directly owned by RBStoryboardLink, in some cases, the view controller doesn't get correctly attached into the view controller hierarchy and unwind segues break.

The trick for me was to perform a segue only in viewDidAppear or later. Not the best solution, but that's what worked for me.