How do I instantiate a view controller with a tab and nav controller for deep binding?

I am deeply linking to my application and am having difficulty instantiating the application. For my app link, it opens the details page for the blog post, so I create it like this:

var controller = PostDetailController()

      

The problem is there is no navigation header or tabs at the bottom. How do I properly start the application from the beginning and then load mine PostDetailController

?

Below is an example of my storyboard and I am trying to link it directly to my "Message Controller", but with all the previous controllers, how do I do that? enter image description here

+3


source to share


1 answer


There are many different ways to do this. Assuming you're starting with a delegate method openURL:

, here's a high-level view for one way to do it.

  • From the method, openURL:

    parse the required parameters from url

    and store it in a global var.
  • Subclass UITabBarController

    and create a function to handle deep linking. This function should evaluate the global set of variables in the application delegate and determine which tab and view should be displayed.


For example:

        // Check for deep link global var

        if (myGlobalVar==1){
            //Instantiate the destination view (the view you want the deep link to show)
            DetailViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"myDetailView"];

            //set any vars need in the destination view

            //Push the detail View to stack of the to be seleceted Tab
            [[self.viewControllers objectAtIndex:myTABINDEX] pushViewController:detailViewController animated:NO];

            //select the tab to the destination view
            [self setSelectedIndex:myTABINDEX];

        } 

      

+4


source







All Articles