I am working on an IPhone app that, through viewDidLoad, makes a connection and pulls data into a table. I would like the controller, or at least the table, to reload every time the controller is displayed, even if someone just switched from one tab to another or closed and re-opened the app on this controller. Is there a way to do this? I can’t seem to find anything, it’s also kind of a hard thing to search for. I have found discussions of when to put code in viewDidLoad but not another method that is run every them the controller displays.
Thanks,
Cheryl
There’s no way to do it by injecting code in only one place.
You can think of a workaround, like for example sending custom “reload request” notification from required parts of code:
viewDidAppear:in your view controllerapplicationDidBecomeActive:(if table is presented)tabBarController:didSelectViewController:(if switched onto controller with the table)tabBar:didSelectItem:(same as above)In you view controller simply observe this notification and reload data when required.
Although, whats more important: do you really need to reload data under such harsh requirements? In most cases data reload happens when
viewDidLoad:is calledOtherwise it’s just an overkill.