我正在尝试创建Siri快捷方式,并且我希望该快捷方式转到其他ViewController,而不仅仅是根目录。怎么做?以下是当前的App Delegate代码。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
print(userActivity.activityType)//com.myvisionapps.Meditate.begin
if(userActivity.activityType == "com.myvisionapps.Meditate.begin") {
if let controller = window?.rootViewController as? ViewController {
}
}
return false
}
答案 0 :(得分:0)
您可以使用此代码AppDelegate,它变得不错了:
let mainStoryboardIpad : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewControlleripad : yourViewController = mainStoryboardIpad.instantiateViewController(withIdentifier: "yourViewControllerIdentifire") as! yourViewController
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = initialViewControlleripad
self.window?.makeKeyAndVisible()
// now you can use initialViewControlleripad to access to your references in your ViewController