简体   繁体   English

如何深层链接到从UITabBarViewController中的UINavigationController中的UIViewController访问的UIViewController?

[英]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. 我需要深度链接到一个UIViewController,可以从另一个UIViewController中访问该UIViewController,该UIViewController本身是UITableViewController中的一个选项卡,该UINavigationViewController驻留在该UINavigationViewController中。

Basically it looks like this 基本上看起来像这样

UITabBarViewController -> (Each Tab) UINavigationController -> UIViewController -> (Press UIBarButtonItem) -> TheViewControllerIWant UITabBarViewController->(每个选项卡)UINavigationController-> UIViewController->(按UIBarButtonItem)-> TheViewControllerIWant

Due to the constraints of the project I'm working on, this has all been created programmatically in my AppDelegate. 由于我正在处理的项目的限制,所有这些都已在我的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 它使我进入ViewController,但没有给我导航回到选项卡中的ViewController的方法

- (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: 我也尝试过这样做,但没有办法从TabBar中的导航器向前导航到下一个ViewController:

- (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上的第一个选项卡,然后需要获取第一个Tab的UIViewController并将目标ViewController推入导航控制器中。

[_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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从UIViewController访问UINavigationController - How to access UINavigationController from a UIViewController 如何从UIViewController过渡到UINavigationController - How to transition to a UINavigationController from a UIViewController 从UIViewController呈现UINavigationController - Present UINavigationController from UIViewController 从UIViewController推送UINavigationController - Push UINavigationController from UIViewController 从 uinavigationcontroller 中查找 uiviewcontroller - Find a uiviewcontroller from uinavigationcontroller 从UINavigationController展开到UIViewController - Unwind from UINavigationController to UIViewController UINavigationController和UIViewController如何工作? - How UINavigationController and UIViewController works? 如何从UINavigationController选择到UIViewController - How do I segue from a UINavigationController to a UIViewController 如何以编程方式从UINavigationController(storyboard)到UIViewController - How to segue from UINavigationController (storyboard) to UIViewController programmatically 如何在不导入第一个UIViewController类的情况下从UINavigationController中的另一个UIViewController手动取消分配UIViewController? - How can I dealloc manually UIViewController from another UIViewController in UINavigationController without import the first UIViewController class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM