使用3D Touch Quick Action问题

时间:2015-12-04 15:43:21

标签: ios swift

所以我在我的应用程序中使用快速操作,但我遇到了问题。 enter image description here

您可以看到,当应用程序打开“欢迎”视图控制器时,一秒后它会打开第一个标签栏项目。我有三个快速行动:

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {

        let rootNavigationController = window!.rootViewController as? UINavigationController
        let tabbarController = window!.rootViewController as? UITabBarController

        rootNavigationController?.popToRootViewControllerAnimated(false)

        if shortcutItem.type == "FEED" {
            print("Shortcut item tapped: FEED")
            // go to FEED view controller
            tabbarController!.selectedViewController = tabbarController!.viewControllers?[0]
        }
        if shortcutItem.type == "EXPLORE" {
            print("Shortcut item tapped: EXPLORE")
            // go to EXPLORE view controller
            tabbarController!.selectedViewController = tabbarController!.viewControllers?[1]
        }
        if shortcutItem.type == "UPLOAD" {
            print("Shortcut item tapped: UPLOAD")
            // go to UPLOAD view controller
            tabbarController!.selectedViewController = tabbarController!.viewControllers?[2]
        }
    }

我的应用程序在tabbarController!.selectedViewController代码中崩溃了。有什么想法吗?

0 个答案:

没有答案
相关问题