Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从didFinishLaunchingWithOptions调用3D Touch快速操作时不起作用_Ios_Swift_3dtouch - Fatal编程技术网

Ios 从didFinishLaunchingWithOptions调用3D Touch快速操作时不起作用

Ios 从didFinishLaunchingWithOptions调用3D Touch快速操作时不起作用,ios,swift,3dtouch,Ios,Swift,3dtouch,我正在我的应用程序中实施3D touch快速操作,我有以下问题: 当应用程序已经在运行,因此通过对快捷方式项执行操作来启动快速操作时,它工作得非常好。但是,当应用程序被终止,然后通过快速操作启动时(因此didFinishLaunchingWithOptions),它不会将我带到所需的视图控制器,而是带到应用程序的主屏幕 这是我的密码: func application(_ application: UIApplication, didFinishLaunchingWithOptions laun

我正在我的应用程序中实施3D touch快速操作,我有以下问题: 当应用程序已经在运行,因此通过对快捷方式项执行操作来启动快速操作时,它工作得非常好。但是,当应用程序被终止,然后通过快速操作启动时(因此didFinishLaunchingWithOptions),它不会将我带到所需的视图控制器,而是带到应用程序的主屏幕

这是我的密码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        //... other stuff I'm doing

        if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
        shortcutItemToProcess = shortcutItem
    }
    return true
注意:我已经阅读了之前的SO答案,他们说当应用程序通过快速操作启动时,我需要在didFinishLaunchingWithOptions中返回false,这样performAction就不会被调用。我需要始终返回true,但是在我的didfishLaunching方法中,因为我正在处理其他事情。然而,我试图返回false,只是想看看这是否会导致问题,并且应用程序仍然以相同的方式运行

    func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
          shortcutItemToProcess = shortcutItem
    }
以下是我演示视图控制器的方式:

    func applicationDidBecomeActive(_ application: UIApplication) {

    if let shortcutItem = shortcutItemToProcess {
        if shortcutItem.type == "com.myName.MyApp.myQuickAction" {
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let myViewController = storyboard.instantiateViewController(withIdentifier: "myViewController") as! MyViewController

            if let navVC = window?.rootViewController as! UINavigationController? {
                navVC.pushViewController(myViewController, animated: true)
            }
        }

所以,当应用程序已经运行时,这可以正常工作,但当应用程序被终止时,它会将我放在应用程序的主页上。我做错了什么?我该如何解决这个问题?

你有没有找到解决方案?