简体   繁体   中英

How to deeplink to a UIViewController accessed from a UIViewController in a UINavigationController in a UITabBarViewController?

I need to deeplink to a UIViewController that can be accessed from another UIViewController that resides in a UINavigationViewController which itself is a tab in a UITableViewController.

Basically it looks like this

UITabBarViewController -> (Each Tab) UINavigationController -> UIViewController -> (Press UIBarButtonItem) -> TheViewControllerIWant

Due to the constraints of the project I'm working on, this has all been created programmatically in my AppDelegate. I cannot use Storyboards to solve this problem.

Here is my existing code. It gets me to the ViewController, but does not give me a way to navigate back to the ViewController in the tab

- (BOOL) application: (UIApplication * ) application openURL: (NSURL *) url sourceApplication: (NSString *) sourceApplication annotation: (id) annotation {

    if ([url.scheme isEqualToString: @"myApp"]) {

        if ([url.host isEqualToString: @"account"])
        {
            self.window.rootViewController = [[EditAccountViewController alloc] init];
        }
}

I have also tried this as a start, but have no way to navigate forward to the next ViewController from the one in the TabBar to it:

- (BOOL) application: (UIApplication * ) application openURL: (NSURL *) url sourceApplication: (NSString *) sourceApplication annotation: (id) annotation {

    if ([url.scheme isEqualToString: @"myApp"]) {

        if ([url.host isEqualToString: @"account"])
        {
            [_tabBarController setSelectedIndex:0];
            self.window.rootViewController = _tabBarController;
        }
    }
}

How do I accomplish this

Well you need to manually trigger all actions then....

So you'll need to first select the first tab on your TabBarController Then you'll need to get the UIViewController of the first Tab and push the destination ViewController in the Navigation Controller...

[_tabBarController setSelectedIndex:0];
UIViewController *myVC = self.tabBarController.viewControllers.firstObject;
UIViewController *destinationVC = [[UIViewController alloc] initWithNibName:@"vc.nib" bundle:[NSBundle mainBundle]];
[myVC.navigationController pushViewController:destinationVC animated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM