Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

PKRevealController doesn't play well with unwind segues #211

Open
banaslee opened this issue Aug 6, 2014 · 0 comments
Open

PKRevealController doesn't play well with unwind segues #211

banaslee opened this issue Aug 6, 2014 · 0 comments

Comments

@banaslee
Copy link

banaslee commented Aug 6, 2014

I had a problem on iOS 8 when the view controller chosen to start querying for a unwind action handler was a PKRevealController.

PKRevealController is unable to provide the right handler from its hierarchy and the action is left unhandled.

My solution was to override - viewControllerForUnwindSegueAction:fromViewController:withSender: like this:

- (UIViewController *)viewControllerForUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)sender {
    NSArray *children = @[self.frontViewController];
    if (self.leftViewController) {
        children = [children arrayByAddingObject:self.leftViewController];
    }
    if (self.rightViewController) {
        children = [children arrayByAddingObject:self.rightViewController];
    }

    UIViewController *foundViewController;

    for (UIViewController *childViewController in children) {
        foundViewController = [childViewController viewControllerForUnwindSegueAction:action
                                                                   fromViewController:fromViewController
                                                                           withSender:sender];

        if (foundViewController) {
            break;
        }
    }

    if (!foundViewController) {
        foundViewController = [super viewControllerForUnwindSegueAction:action
                                                     fromViewController:fromViewController
                                                             withSender:sender];
    }

    return foundViewController;
}

I'm not able to do a pull request right now. I can only provide with this code for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant