简体   繁体   中英

Do something if view loads

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 (eg 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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM