iOS Deeplink to a specific ViewController retainin

2019-07-29 09:46发布

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:

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

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!

1条回答
Deceive 欺骗
2楼-- · 2019-07-29 10:41

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)

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

查看更多
登录 后发表回答