我已经在 Info.plist 中为我用 Xcode 创建并用 Swift 编写的 iOS 应用程序创建了一些(静态)QuickActions。
我无法让他们打开 ViewController。当然,我已经用谷歌搜索了,但对我没有任何帮助。如果这很重要:我正在使用由 TabBarController 管理的 ViewController。大多数教程似乎都使用 NavigationController。但是,我认为这将与 segues 一起完成,对吧?我需要什么代码来处理它?
请问有人可以提供吗?或者有人知道简单的手册/教程吗?
问候,大卫。
PS:我试过这段代码,但它似乎只适用于 NavigationController?!代码:
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void)
{
self.handleShortcutItem(shortcutItem)
completionHandler(true)
}
func handleShortcutItem(shortcutItem: UIApplicationShortcutItem)
{
switch shortcutItem.type {
case "icons.quickaction.home":
self.presentComposeViewController()
default: break
}
}
func presentComposeViewController()
{
guard let navigationController = window?.rootViewController as? UINavigationController else { return }
let identifier = "MyViewController"
let composeViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier(identifier)
navigationController.pushViewController(composeViewController, animated: false)
}