0
votes

I would like to know why tha't happening: I have 2 view controllers embeded in navigation controller. All have superclass where I have something like that:

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSLog(@"Visible VC: %@",self.navigationController.visibleViewController.class);
}

So far everything works like a charm. Then I added third navigation controller which is the modal view controller. It also has super class like the others. Now I see strange thing. After click button to present modal View controller I see log: "Visible: (null)", but it's ok because third VC is not in navigation controller. When i click dismiss button to hide modal View controller I see 2 logs: "Visible: (null) Visible: ViewController3". My question is: Why visible view controller is not kind of class ViewController2 ? It should be, because third one was dismissed. How can i resolve it ? I need to have visible view controller kind of class View Controller 2.

1

1 Answers

0
votes

I'm guessing that viewController2 is not the visible one yet when that is called.

Try accessing it in

viewDidAppear

instead of viewWillAppear.

Or, you can try to access the

self.navigationController.topViewController

property instead, that should return viewController2.