views:

111

answers:

1

Hi,

I shift to my view by

[[self navigationController] popToViewController:controller animated:YES];

In that ViewController, I'm not able to get a notice, that it comes back to front (e.g. by viewWillAppear). I want to reload a table, as soon as the view is visible again.

How do I get a notice, that the view comes back on the screen?

----> solved: See my last comment on Corey's answer

+2  A: 

viewWillAppear should be called if you are using a UINavigationController.

Are you sure you have added it correctly to the view hierarchy?

Did you check if viewWillDisappear gets called when it goes offscreen?

Did you try viewDidAppear just to make sure?

Did you spell the method name correctly?


To add:

Is the instance of UINavigationController added directly to the UIWindow instance?

The delegate methods like viewWillappear are sent from UIApplication (I believe). UIApplication only "knows" about viewControllers whose views are either:

  1. Added Directly to UIWindow.

  2. Added to a UINavigationController/UITabBarCOntroller that is added directly to UIWindow (or a chain of these that leads to UIWindow).

Corey Floyd
Thanks for your answer. I can't see anything wrong. Events like viewWillDisappear, viewDidAppear don't get called, too :-(I added the view like this:AddBoxViewController *addBoxController = [AddBoxViewController alloc];[addBoxController initWithNibName:@"AddBox" bundle:[NSBundle mainBundle]];[self.navigationController pushViewController:addBoxController animated:YES];
Stefan
generally when viewDidLoad gets called but the viewWillAppear/DidAppear methods DON'T get called, the view isn't added properly to the hierarchy. Do any other views in the navigation controller get these messages? Also, is the UINavigationController added directly to the instance of UIWindow? If not, then you won't receive those messages.
Corey Floyd
Ahhh. Ok, I see.That was the error: I've implemented viewWillAppear the wrong way:- (void) viewWillAppear {...}correct is:- (void)viewWillAppear:(BOOL)animated {...}Corey, thank you for pointing me in the right direction.
Stefan