ios - 如何使用选项卡和导航 Controller 实例化 View Controller 以进行深度链接?

标签 ios swift uiviewcontroller uinavigationcontroller uitabbarcontroller

我正在为我的应用实现深层链接,但无法正确实例化我的应用。对于我的应用程序链接,它打开了博客文章的详细信息页面,因此我将其实例化如下:

var controller = PostDetailController()

问题是底部没有导航标题或标签栏。如何从头开始正确启动我的应用程序,然后加载我的 PostDetailController

下面是我的 Storyboard的样子,我试图直接链接到我的“后期细节 Controller ”,但它后面有所有以前的 Controller ,我该怎么做? enter image description here

最佳答案

有很多不同的方法可以实现这一点。假设您从应用委托(delegate)的 openURL: 方法开始,这里是一种方法的高级 View 。

  1. openURL: 方法中,从url 中解析出需要的参数,并将其存储在一个全局变量中。
  2. 子类化您的 UITabBarController 并创建一个函数来处理深层链接。此函数应评估应用程序委托(delegate)中设置的全局变量并确定需要显示哪个选项卡和 View 。

例如:

        // 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];

        } 

关于ios - 如何使用选项卡和导航 Controller 实例化 View Controller 以进行深度链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31435135/

相关文章:

ios - "Could not locate google-services.json or GoogleService-info.plist files"iOS项目、Unity、Mac电脑

IOS 图像约束在设备中无法正常工作

ios - 如何将 tableview 单元格保存到 UserDefaults 然后显示它

iOS 从另一个类更新 ViewController UILabel

ios - Sprite 有时会消失 [Sprite Kit]

ios - 使用 swift 发起 HTTP GET 请求

ios - swift : get all installed application and open specific one

ios - 如何将多个参数传递给 Swift #selector?

ios - 在没有动画时处理自定义过渡的结束?

uiviewcontroller - 进入UINavigationController(Storyboard)之前的欢迎屏幕