[英]Present a ViewController from the AppDelegate
我在Info.plist
设置了3D强制触摸动作。 现在,我希望当3D Action运行时,它提供一个视图控制器,该控制器提供了一个Storyboard ID,我需要在AppDelegate
执行此操作。
我使用了performActionForShortCutItem
函数。
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if let tabVC = self.window?.rootViewController as? UITabBarController {
if shortcutItem.type == "Hausaufgaben" {
tabVC.selectedIndex = 1
tabVC.performSegue(withIdentifier: "gotoHausaufgaben", sender: nil)
}
}
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "Hausaufgaben" {
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "YOUR PAGE Identifier")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.