Skip to content

Instantly share code, notes, and snippets.

@y8k
Created October 26, 2015 05:11
Show Gist options
  • Save y8k/d84d5bb614c949b82782 to your computer and use it in GitHub Desktop.
Save y8k/d84d5bb614c949b82782 to your computer and use it in GitHub Desktop.
AppDelegate methods for Home screen quick actions
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
self.handleShortCutItem(shortcutItem)
}
func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) {
guard let rootViewCntrlr = self.window?.rootViewController else {
return
}
if rootViewCntrlr.presentedViewController != nil {
let viewCntrlr = rootViewCntrlr.presentedViewController
viewCntrlr?.dismissViewControllerAnimated(false, completion: nil)
}
let storyboard = UIStoryboard(name: "Main", bundle: nil)
guard let presentNavigation = storyboard.instantiateViewControllerWithIdentifier("PRESENT_NAVIGATION_SCREEN") as? UINavigationController else {
return
}
guard let viewCntrlr = presentNavigation.topViewController as? PresentedViewController else {
return
}
viewCntrlr.shortCutItem = shortcutItem
rootViewCntrlr.presentViewController(presentNavigation, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment