0

I have a LocalNotification which invokes the application.

In the application, almost all view are connected with NavigationController to show header bar and the "global menu".

When the application was invoked by the action from the Notification, the AppDelegate must call a WebView containing the "global menu". That means, I have to add this "WebView" to the application's NavigationController.

Firstly, I tried something like this:(in AppDelegate)

UIViewController *currentVc = self.window.rootViewController;
[currentVc.navigationController pushViewController:orderVc animated:NO];  

But it won't display anything. So I have tried this way:

UIViewController *currentVc = self.window.rootViewController;
[currentVc presentViewController:orderVc animated:NO completion:nil];  

Then the WebView(currentVc) displays but it's not under the whole app's Navigation Controller, so no "global menu".

I have checked if UIViewController (self.window.rootViewController) was nil but it's not.

I have searched around and found many similar questions but they're all opposit of my case.

Are there any simple way to add ViewController to the NavigationController to show "header bar"? Sorry for too vague question, but I really need help again.

Thanks in advance.

Faust V
  • 667
  • 1
  • 9
  • 19
  • Do you adding navigationController from nib file? – Anil Varghese Jan 31 '13 at 15:18
  • Yes. I'm using storyboard to create the navigationController. When instantiate the WebViewController, I use WebViewController *orderVc = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"webviewcontroller"]; In most of the cases, it's just fine with pushViewController. But from the AppDelegate, although I can use presentViewController (which seems indicate that self.window.rootViewController is not nil), push won't work. – Faust V Jan 31 '13 at 21:04

1 Answers1

0

Each view controller has control of its own navigationItem. If you want to display buttons/titles for a VC that you push, then you must update the navigationItem. Usually viewWillAppear is a good place for it.

logancautrell
  • 8,762
  • 3
  • 39
  • 50
  • Thanks for the advise. But I just wanted to add a viewcontroller to the existing navigationController hierarchy. Sorry for my English, it's a little bit hard to explain this problem... – Faust V Jan 31 '13 at 21:09