iOS Deeplink到保留视图控制器堆栈的特定ViewController [英] iOS Deeplink to a specific ViewController retaining view controller stack

查看:64
本文介绍了iOS Deeplink到保留视图控制器堆栈的特定ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的客户开发一个应用程序,他们希望能够从终止的应用程序到特定视图控制器的深层链接。这是当前的堆栈:

I'm developing an app for a client of mine and they want to be able to deeplink to a specific view controller from the app being terminated. Here is the current stack:


  • 启动屏幕

  • 启动屏幕(在此处下载我们的配置文件)

  • VC1

  • VC2

  • VC3

  • VC4

  • VC5

  • Launch Screen
  • Splash Screen (Here is where we download our config file)
  • VC1
  • VC2
  • VC3
  • VC4
  • VC5

客户端希望通过深度链接启动应用程序的能力,并且在启动画面完成配置文件下载后,导航到特定的视图控制器(VC1-VC5)。问题是他们想保留堆栈。因此,我不能简单地从启动屏幕中推送VC5,因为VC5需要能够返回到VC4的能力,而不是VC3而不是VC2,等等。

The client wants the ability, via a deeplink, to launch the app, and after the Splash Screen completes the config file download, to navigate to a specific view controller (VC1-VC5). The issue is that they want to retain the stack. So i cannot simply push VC5 from the Splash Screen because VC5 needs the ability to go back to VC4 than VC3 than VC2, etc.

什么是最好的处理方式?任何帮助将不胜感激。

What is the best way to handle this? Any help would be greatly appreciated. Thanks in advance!

推荐答案

您可以使用UINavigationController setViewControllers方法一次设置所有导航堆栈。只需为每个视图控制器创建一个实例,然后将其传递给您的导航控制器,如下所示:

You can set a navigation stack all at once by using the UINavigationController setViewControllers method. Just create an instance of each view controller and pass them to your nav controller like this:

navController.setViewControllers([vc1, vc2, vc3, vc4, vc5], animated: true)

请注意,这将覆盖所有视图当前在导航堆栈中的控制器。 vc1将成为导航控制器的根vc。

Just be aware that this will overwrite all view controllers currently in the navigation stack. vc1 would become your navigation controller's root vc.

这篇关于iOS Deeplink到保留视图控制器堆栈的特定ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆