Created
October 26, 2015 05:11
-
-
Save y8k/d84d5bb614c949b82782 to your computer and use it in GitHub Desktop.
AppDelegate methods for Home screen quick actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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