-1

I have an issue with UINavigationController.

I have a container view (designed in .xib file). Also, I have a view controller.

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];

[self.containerView addSubview:navigationController.view];

Because of reasons I am not aware of, view controller's self.viewController view is not initialised (method - viewWillAppear is not being called).

I wonder, why method - viewWillAppearis not called and how to change that?

Daumantas Versockas
  • 797
  • 1
  • 10
  • 29
  • how do you think adding it as subview initialises the view ? – Teja Nandamuri Sep 10 '15 at 12:21
  • I think you should add self.view insted of self.containerView. may it's wrong – Sandy Patel Sep 10 '15 at 12:37
  • @Mr.T adding subview is not causing this issue. When I add `[self.containerView addSubview:self.viewController.view];` it works fine, because it just adds subview as it is and `self.viewController` is responsible for methods calling. – Daumantas Versockas Sep 10 '15 at 15:29
  • @SandyPatel No, I am using a container view. In my situation it is common practice. But the problem is that navigation controller doesn't initialise his root view controller. – Daumantas Versockas Sep 10 '15 at 15:30

2 Answers2

-1

When a view called first when the view created

  • viewDidLoad called

but - viewWillAppear/- viewDidAppear not called

when when navigation controller push another controller and back again then viewWillAppear cal.

Jamil
  • 2,977
  • 1
  • 13
  • 23
-1
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.TestController];

[self.view addSubview:navigationController.view];
Sandy Patel
  • 768
  • 7
  • 19
  • My issue has nothing in common with `- application:didFinishLaunchingWithOptions:` method... – Daumantas Versockas Sep 10 '15 at 11:47
  • so u need navigationController on Perticular ViewController? You just Implement this code may be it's solve your problem. please check it one time then after tell me if any problem. – Sandy Patel Sep 10 '15 at 11:49
  • I have to add navigation controllers view in specific container view. If I am doing like `[self.containerView addSubview:view.controller.view]` everything goes fine. But, I need navigation hierarchy in my situation, so thats why I am adding `UINavigationController`. In my given example I see a navigation controller (navigation bar), but I don't see view controller inside... – Daumantas Versockas Sep 10 '15 at 11:52