我正在为我的应用实现深层链接,但无法正确实例化我的应用。对于我的应用程序链接,它打开了博客文章的详细信息页面,因此我将其实例化如下:
var controller = PostDetailController()
问题是底部没有导航标题或标签栏。如何从头开始正确启动我的应用程序,然后加载我的 PostDetailController
?
下面是我的 Storyboard的样子,我试图直接链接到我的“后期细节 Controller ”,但它后面有所有以前的 Controller ,我该怎么做?
最佳答案
有很多不同的方法可以实现这一点。假设您从应用委托(delegate)的 openURL:
方法开始,这里是一种方法的高级 View 。
- 从
openURL:
方法中,从url
中解析出需要的参数,并将其存储在一个全局变量中。 - 子类化您的
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/