0

I want a new View Controller as a pop-up (which have some Parents View Controller scene ). So i am decided to add childViewController (which have 50px transparent border from all side.) Now when i adding childViewController i didn't get navigationBar. This is how i am adding full sized childViewController.

    ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];

    UINavigationController *childNavController = [[UINavigationController alloc] initWithRootViewController:postvcObj];
  [self.navigationController addChildViewController:childNavController];
  [self.navigationController.view addSubview:postvcObj.view];
  [postvcObj didMoveToParentViewController:self];

How i can i get real navigation Bar on childViewController.

Gaurav Pandey
  • 1,953
  • 3
  • 23
  • 37

2 Answers2

0

The correct way of showing a new ViewController is via UINavigationController's pushViewController:animated. Then the new ViewController has a NavigationBar:

ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];
[self.navigationController pushViewController:postvcObj animated:true]; 
Hannes
  • 3,752
  • 2
  • 37
  • 47
-1

Instead of instantiating a new UINavigationController just use the following:

ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];
[self.navigationController pushViewController:postvcObj];
nburk
  • 22,409
  • 18
  • 87
  • 132