0

I`m using this code in AppDelegate for make a shortcut when you long press the app before its launch.

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
    if(shortcutItem.type == "com.skalstad.addStuff")
    {
        let sb = UIStoryboard(name: "Main", bundle: nil) 
        let add =  sb.instantiateViewControllerWithIdentifier("AddTableViewController") as! AddTableViewController

        let root = UIApplication.sharedApplication().keyWindow?.rootViewController

        root?.presentViewController(add, animated: false, completion: {() -> Void in


            completionHandler(true)


        })
    }
}

When i open the shortcut, the viewController is full screen,no NavigationController or TabBarController. Anyone with this same issue or have a solution?

Alexey Pichukov
  • 3,377
  • 2
  • 19
  • 22
Scaly
  • 1
  • 2

1 Answers1

0

You're presenting a view controller modally, which means no tab bar controller and no navigation controller.

If you want to see either, you can either use a segue programatically (see the "Initiating a Segue Programmatically" section of that document) to push to your "AddTableViewController" or connect your tab bar controller to an outlet and then select the tab that has your "AddTableViewController". No need to instantiate your main storyboard again (it's already loaded into memory when your app is launched).

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215