如何使用 UIApplicationShortCut 和 NavigationController 导航以获取孩子 4

Posted

技术标签:

【中文标题】如何使用 UIApplicationShortCut 和 NavigationController 导航以获取孩子 4【英文标题】:How to navigate with UIApplicationShortCut and NavigationController to get to get child 4 【发布时间】:2016-03-25 22:45:37 【问题描述】:

案例: 我有一个拥有TabBarcontroller 的应用程序,其中TBC 我有一个NavigationController。我想在这个应用程序中添加ApplicationShortcuts。 但是,其中一个需要位于选项卡 1 上,并且 4 位于导航控制器中。我如何做到这一点?

我可以通过使用NSNotificationCenter 并在第一层使用监听器来访问第一个。但这需要我的应用程序之前打开..尝试发送另一个通知失败..

我的故事板:

从变量控制器 -> 导航控制器 -> 表格视图(年份-- 在此处打开)-> 表格视图(周期 - 如果之前打开过应用程序可以到达此处)-> 表格视图(周)-> 选择器视图。 (完)

我应该使用哪个函数来实现预期目标?

【问题讨论】:

【参考方案1】:

几个小时后,我发现了如何执行上述操作。

在主类ViewDidLoad中:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "quickActions:", name: "quickAction", object: nil)

然后是一个监听器:

func quickActions(notification: NSNotification)
    print(notification.userInfo!)
    varDec.pressedYear = "2016" //used for the right year. (dynamical)
    varDec.pressedWeek = "13" //Used to show the right dates.
    let VC1 = self.storyboard!.instantiateViewControllerWithIdentifier("weekViewController") as! UIViewController
    self.navigationController!.pushViewController(VC1, animated: true)

让我有资格导航到任何 ViewController 而不会丢失我的 UINavigationController

【讨论】:

以上是关于如何使用 UIApplicationShortCut 和 NavigationController 导航以获取孩子 4的主要内容,如果未能解决你的问题,请参考以下文章

如何使用本机反应创建登录以及如何验证会话

如何在自动布局中使用约束标识符以及如何使用标识符更改约束? [迅速]

如何使用 AngularJS 的 ng-model 创建一个数组以及如何使用 jquery 提交?

如何使用laravel保存所有行数据每个行名或相等

如何使用 Math.Net 连接矩阵。如何使用 Math.Net 调用特定的行或列?

WSARecv 如何使用 lpOverlapped?如何手动发出事件信号?