我正在为我的应用程序实现深层链接,但无法正确实例化我的应用程序。对于我的应用程序链接,它打开了一个博客文章的详细信息页面,所以我像这样实例化它:
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/