1

我正在尝试在我的应用程序中实现 3D Touch 快捷方式,但我不确定如何处理我在标签栏中有一个导航栏的事实,如果我将 rootViewController 声明为我的导航栏,那么我的快捷方式可以工作,但是当快捷方式屏幕被关闭,我没有标签栏。这是我的故事板的链接方式,我不知道在这里做什么。

红色是我想要去的地方

我正在努力达到红点。

@available(iOS 9.0, *)
func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) -> Bool {
    var handled = false

    if let shortcutType = ShortcutType.init(rawValue: shortcutItem.type) {

        let tabBarController = UITabBarController()

        let storyboard = UIStoryboard(name: "Main", bundle: nil)

        let rootController = storyboard.instantiateViewControllerWithIdentifier("MainTabBar") as! UITabBarController

        let tradesNav = storyboard.instantiateViewControllerWithIdentifier("TradeNavigation")

 //            if self.window != nil {
            self.window!.rootViewController = rootController
 //            }


        // Get root navigation view controller and its first controller
        let rootNavigationViewController = window!.rootViewController as? UINavigationController
        let rootViewController = rootNavigationViewController?.viewControllers.first as UIViewController?
        // Pop to root view controller so segue can be handled

        rootNavigationViewController?.popToRootViewControllerAnimated(true)

        switch shortcutType {
        case .newTrade:
            tradesNav.performSegueWithIdentifier("newTradeModal", sender: nil)
            handled = true
        }
    }
    return handled
}
4

0 回答 0