簡體   English   中英

如何深層鏈接到從UITabBarViewController中的UINavigationController中的UIViewController訪問的UIViewController?

[英]How to deeplink to a UIViewController accessed from a UIViewController in a UINavigationController in a UITabBarViewController?

我需要深度鏈接到一個UIViewController,可以從另一個UIViewController中訪問該UIViewController,該UIViewController本身是UITableViewController中的一個選項卡,該UINavigationViewController駐留在該UINavigationViewController中。

基本上看起來像這樣

UITabBarViewController->(每個選項卡)UINavigationController-> UIViewController->(按UIBarButtonItem)-> TheViewControllerIWant

由於我正在處理的項目的限制,所有這些都已在我的AppDelegate中以編程方式創建。 我無法使用情節提要來解決此問題。

這是我現有的代碼。 它使我進入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];
        }
}

我也嘗試過這樣做,但沒有辦法從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;
        }
    }
}

我該怎么做

那么,您需要手動觸發所有操作。

因此,您需要首先選擇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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM