0

I have my TabBarController as my initial view (storyboard identity Main) (Class UITabBarController) Then a NavigationController (storyboard id = ViewController) (Class UINavigationController).

Then my ViewController (storyboard id = View) (Class ViewController)

Then my Details (storyboard id = StoryDetails) (Class Details)

I would like to navigate from AppDelegate.swift to the Details.swift uiviewcontroller.

func application(application: UIApplication,  didReceiveRemoteNotification userInfo: [NSObject : AnyObject],  fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { 
let storyboard = UIStoryboard(name: "Main", bundle: nil)
        if let tabViewController = storyboard.instantiateViewControllerWithIdentifier("StoryDetails") as? UITabBarController {
            window!.rootViewController!.presentViewController(tabViewController, animated: true, completion: nil)
        }

But this is not working

Help would be really appreciated! (:

Also

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let detail = storyboard.instantiateViewControllerWithIdentifier("StoryDetails") 
self.window?.rootViewController!.presentViewController(detail, animated: true, completion: nil)

This code brings up the view, but there is no navigation controller or tab bar controller

user2643679
  • 706
  • 12
  • 18
  • What message did the console give you – Knight0fDragon Nov 23 '15 at 19:39
  • The identifier would be `"StoryDetails"` not `"Details"` if everything you've included is correct. – Andrew Nov 23 '15 at 19:44
  • Sorry, i changed the question, I had StoryDetails as the identifier. It just loads the intial controller like normal, let storyboard = UIStoryboard(name: "Main", bundle: nil) let detail = storyboard.instantiateViewControllerWithIdentifier("StoryDetails") self.window?.rootViewController!.presentViewController(detail, animated: true, completion: nil) This code brings up the view, but there is no navigation controller or tab bar controller – user2643679 Nov 23 '15 at 20:02
  • I removed the if let, and checked print(tabviewcontroller) came up nil @Knight0fDragon – user2643679 Nov 23 '15 at 20:22
  • .. when you go to present the view controller, the console should give you a message explaining why it is failing, if it doesn't, then I would check to see if window is not nil – Knight0fDragon Nov 23 '15 at 20:27
  • @Knight0fDragon the window is nil, but I don't know why, i've tried : as NavigationController = nil as TabBarController = nil as ViewController works, but i'm back at the initial page... – user2643679 Nov 23 '15 at 20:31
  • well 1st of all, why are we doing this in the app delegate, perhaps this is not the correct place to be doing this – Knight0fDragon Nov 23 '15 at 20:36
  • @Knight0fDragon it has to be done in the app delegate because of the receiveremotenotification , as i'm receiving a payload from a push notification – user2643679 Nov 23 '15 at 20:44
  • that message could be received anyway where, maybe this can help you: http://stackoverflow.com/questions/31610896/controlling-which-view-controller-loads-after-receiving-a-push-notification-in-s – Knight0fDragon Nov 23 '15 at 20:45
  • @Knight0fDragon , I got it working, thanks a lot, not sure if it's possible doing it the way I was but the link you gave me sorted it using the nsnotificationcenter. – user2643679 Nov 23 '15 at 21:44

0 Answers0