Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route to already instantiated ViewControllers #85

Closed
crsantos opened this issue Jan 12, 2016 · 2 comments
Closed

Route to already instantiated ViewControllers #85

crsantos opened this issue Jan 12, 2016 · 2 comments
Labels

Comments

@crsantos
Copy link

This is mostly a question (you can tag it as question), on what's the best approach to route a deeplink to an already instantiated UIViewController.
Like having N viewControllers on a UITabBarController, I would like to have one of them to present itself or push another one to the stack.

I guess this could be done with a block like this, where I have available the existingTargetVC:

    self.router[@"link"]    = ^(DPLDeepLink *link) { 
        [weakself.existingTargetVC doSomeForwardNavigation];
    };

but I can't see any way to do it in a DPLRouteHandlersubclass. I would prefer to have that logic separated.

Any ideas?

@wessmith
Copy link
Member

Hi @crsantos. You should be able to achieve what you want in a DPLRouteHandler subclass by overriding 3 methods.

  1. Override - (UIViewController <DPLTargetViewController> *)targetViewController and return the already instantiated view controller you want.
  2. Override - (UIViewController *)viewControllerForPresentingDeepLink:(DPLDeepLink *)deepLink and return the view controller you want the target view controller presented, pushed, etc. from (e.g. navigation controller, tab bar controller, some custom container controller, or just another view controller)
  3. Override - (void)presentTargetViewController:(UIViewController <DPLTargetViewController> *)targetViewController inViewController:(UIViewController *)presentingViewController. You can do whatever you want here. You have the presenting controller and the target view controller. If your presenting controller is a tab bar controller, you can change the selected tab to the view controller that is your target view controller. If its a navigation controller, make the top view controller your target view controller, etc.

Make sense?

@crsantos
Copy link
Author

Makes a lot of sense. I'll try that approach. Many thanks for the advice 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants