您可以看到,当应用程序打开“欢迎”视图控制器时,一秒后它会打开第一个标签栏项目。我有三个快速行动:
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
代码中崩溃了。有什么想法吗?