0

I want to launch a childViewController of my initialView when it is launched from sliding or pressing a push notification.

Right now, I can launch to the childView, but the functions do not work. One of the labels I've initiated in the .m file is also not showing.

How can I make sure every function (back button(that pops back to parent), functionButtons in the view, segues it leads to) works properly.

This is my code for loading the view:

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
                                                             bundle: nil];
NotificationsViewController *viewController= [mainStoryboard instantiateViewControllerWithIdentifier:@"NotificationsViewController"];
UINavigationController *nav = [[UINavigationController alloc]
                                   initWithRootViewController:viewController];

[_window setRootViewController:nav];
user3178926
  • 339
  • 1
  • 5
  • 15
  • You are setting it as the root view controller, not pushing it onto the stack. If you want to be able to go back you need a parentViewController which in this case there wouldn't be – CWitty Mar 25 '14 at 19:37
  • @CWitty so how can I push it onto the stack from app delegate? – user3178926 Mar 25 '14 at 22:15
  • Expose whatever your existing navigation controller is and push it on that. – CWitty Mar 25 '14 at 22:16

1 Answers1

0

Problem:

The root view controller provides the content view of the window. Assigning a view controller to this property installs the view controller’s view as the content view of the window. If the window has an existing view hierarchy, the old views are removed before the new ones are installed that is why you cannot see the back button because they no longer exist.

Solution:

Pushes the view controller onto the receiver’s , the navigation bar will provide navigation back to the previous view controller.

NotificationsViewController *viewController = [[NotificationsViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
meda
  • 45,103
  • 14
  • 92
  • 122