0

I am working on a chat application and it has a tab bar in storyboard as root view controller.

stack :

tabbarController(rrot view controller)->view controller(4th index) -> tableViewController -> MyDestinationChatController

Now when the notification comes I want to open the MyDestinationChatController but when I do:

[self.window.rootViewController.navigationController pushViewController:myDestinationChatControllerObjVC animated:YES]

it does not push the view and just open my tabBarController with first index.

I have Googled the issue but not able to find a proper solution. The available solutions do not work and I am not able to understand how to handle it.

Any help is good.

rmaddy
  • 298,130
  • 40
  • 468
  • 517
Neal
  • 37
  • 7
  • you can use nsnotificationcenter for this. http://stackoverflow.com/questions/2191594/send-and-receive-messages-through-nsnotificationcenter-in-objective-c – Ty Lertwichaiworawit Oct 16 '15 at 14:04
  • @tnylee - thanks for the reply. thats my last resort if any thing does not work out then i ll use that only. – Neal Oct 16 '15 at 14:19
  • @Neal You might have to get reference to the 4th ViewController. This might help: http://stackoverflow.com/questions/10688848/how-can-i-get-viewcontroller-from-tabbarcontroller-on-appdelegate – ntsh Oct 16 '15 at 20:24
  • By definition a rootViewController has no parent or presenter, so `self.window.rootViewController.navigationController` will be nil. – Avi Oct 18 '15 at 08:47

1 Answers1

0

I would just present MyDestinationChatController modally. If you need a way to cleanly dismiss the view controller, you can embed it in a navigation controller.

MyDestinationChatController *destVC = ...;

// Set properties as needed

UINavigationController *nav = [UINavigationController alloc] initWithRootViewController:destVC];
self.window.rootViewController presentViewController:nav animated:YES completion:nil];
Avi
  • 7,150
  • 1
  • 18
  • 22